Closed gardhr closed 5 years ago
Yes, it would be slightly faster and cleaner.
Really interesting thing though is that, even so, this library actually runs blazingly fast!
I've made some performance benchmarks comparing this library to other big integer libraries:
http://peterolson.github.io/BigInteger.js/benchmark/
I'd certainly pull in commits changing instances of equals(Integer[0])
, although I doubt there would be any noticeable differences in performance overall. There are probably some bigger bottlenecks in the library.
Sure, why not. While I'm at it I think I'll run the benchmarks again just to see if the effect of the optimization is even measurable. :)
Nah, too much stochastic noise from the random sampling to tell. None of the instances seemed to be performance-critical anyway.
I noticed a few instances in the codebase where equals(Integer[0]) and equals(Integer[1]) are used. Maybe just an over-optimization but wouldn't it be more efficient to use isZero() and isUnit() in those cases?