Blogger Information
Blog 1
fans 0
comment 0
visits 781
Related recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
代码性能提升小技巧
Frank的博客
Original
781 people have browsed it
  1. for循环变量初始化

    for (int i = 0; i < strlen(s); i++)    ×

    for (int i = 0, len = strlen(s); i < len; i++)  √

  2. 在乘以2(或2的整数次幂)或除以2(或2的整数次幂)的时候尽量用位运算来替代。

  3. 尽量减少使用除法运算(可以适当转换为乘法,如条件判断时将if (a == b / c)替换为if (a * c == b)。除法运算需要更多的移位和转换操作)

  4. 多使用+=、-=、*=、/=等复合运算符,以加一为例,效率由高到低是(i++ 、 i += 1 、 i = i + 1)

  5. 尽量使用自带库函数

  6. 数据库查询时尽量不使用数据库计算函数

  7. 避免使用select *

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post