Math.clz()

Brendan Eich brendan at mozilla.org
Sat Mar 3 23:21:11 PST 2012


I'm open to clz/clo. The names perhaps need to be less cryptic... or not.

Allen should weigh in.

/be

Jussi Kalliokoski wrote:
> We're working on JS audio decoders, and one huge performance issue atm 
> is clz() [count leading zeroes], which is a very commonly used 
> algorithm in decoders. We've tried several different approaches and 
> benchmarked them [1], however, different approaches work better on 
> different engines, so optimizing the function is a bit of a no-go, 
> especially if we want to have it fast in the future as well.
>
> So, I thought I'd propose something that would go well with the 
> earlier proposals to extend Math [2]:
>
> Math.clz(number)
>
> This would allow for great speed boost in our decoders if it the JS 
> engine had this built-in and optimized.
>
> While at it, it might be wise to add other related functions as well, 
> such as clo (count leading ones), although not as useful.
>
> Cheers,
> Jussi
>
> [1]: http://jsperf.com/read-leading-zeros/8
> [2]: http://wiki.ecmascript.org/doku.php?id=harmony:more_math_functions
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss


More information about the es-discuss mailing list