当前位置:网站首页>【函数的效率】
【函数的效率】
2022-07-17 05:08:00 【学会放下ta】
函数的效率
1、用宏定义来替换一些简单的函数以提高效率
很明显,这不行,宏定义坑太多,例如上次讲到的运算符优先级问题,就算加了括号还有其他问题,例如如果你是循环迭代调用
#define SQUARE(x) ((x)*(x))
...
int i=0;
while(i<=100)
{
printf("%d\n",SQUARE(i++));//自己试试打印出来是啥,为什么?
}
2、可以使用内联函数提高效率
直接在函数前面加inline,编译的时候函数代码会直接镶嵌到main函数中,不会调用堆栈提高了效率,相当于把函数变为了宏定义,拥有了其的优点,避免了宏的缺点,现在的编译器能自动将一些适合的变为内联函数,如果全部为内联函数则会延长编译过程。
边栏推荐
- JS native object plus attributes
- Cesium 綁定鼠標事件和移除鼠標事件
- Use of log4j
- Web3js development technology
- Performance bottleneck finding - Flame graph analysis
- [ES6] quickly print user information to the page
- 2022年春招最新消息:IT互联网行业平均薪资18500元
- MySQL installation and configuration tutorial (super detailed)
- ambari2.7.5集成es6.4.2
- [AI] action recognition using simple neural network -- Based on coco key points
猜你喜欢

Solve the problem of inconsistent prediction effect between text detection training model and information model based on paddleocr

【全网首发】一个月后,我们又从 MySQL 双主切换成了主-从
![[AI] action recognition using simple neural network -- Based on coco key points](/img/67/cd6be6e070fb5d4d44ee043ebd7fac.png)
[AI] action recognition using simple neural network -- Based on coco key points

聊聊redis分布式锁的8大坑

手把手教你复现Log4j2核弹级漏洞

用Flink SQL流化市场数据2:盘中风险价值

单臂路由配置

Is the software testing training of lemon class reliable? This successful case of counter attack from the training class tells you

用户态协议栈-基于netmap的UDP实现

Shell脚本配置root免密登录到其他主机
随机推荐
Common methods of goframe error handling & use of error codes
Online software testing training institutions lemon class and itest AI platform achieves strategic cooperation
一次全面的性能优化,从5秒优化到1秒
Swagger配置与使用
Pat class B 1017: a divided by B
Talk about 20 negative teaching materials for writing code
单臂路由配置
Router loopback port experiment
SQL injection
UML (use case diagram, class diagram, object diagram, package diagram)
Redis source code analysis 3 implementation of discontinuous traversal
【Es6】forEach,for... in ,for... Of column, which allows you to quickly distinguish the usage and differences of various for statements through project cases (full version). There are detailed notes ins
Talk about the 8 pits of redis distributed lock
Wechat applet learning notes
2020-10-22
Network command: network card information, netstat, ARP
The first smart contract program faucet sol
ambari 2.7.5集成安装hue 4.6
Easypoi之excel模板导出
MySQL lock