paulmillr / es6-shim

ECMAScript 6 compatibility shims for legacy JS engines
http://paulmillr.com
MIT License
3.11k stars 387 forks source link

more efficient Math.clz32 #327

Closed Yaffle closed 9 years ago

Yaffle commented 9 years ago

see http://jsperf.com/read-leading-zeros/23

Yaffle commented 9 years ago

OK, seems, everything can be simpler What about new code?

ljharb commented 9 years ago

The code looks great, and is clearly much faster than the existing implementation.

However, according to the jsperf, the overall fastest is "usingBitwiseOperations", not "usingLogarithm". Any reason not to use the bitwise method?

Yaffle commented 9 years ago

@ljharb , bitwise method is bigger and uses 1) bitwise operations; 2) hardcoded precomputed constants

ljharb commented 9 years ago

OK, let's merge this now, and consider the bitwise approach in the future.