不要使用 for in 循环来遍历数组成员 使用倒序循环,速度较快 达夫设备(Duff's Device):循环展开,如果循环次数超过 1000 ,则会有很大提升
双语例句
1
The most well known approach to limiting loop iterations is a pattern called Duff'sDevice.
最广为人知的限制循环迭代次数的模式称作“达夫设备”。
2
Whether or not it's worthwhile to use Duff'sDevice, either the original or the modified version, depends largely on the number of iterations you're already doing.