Sugar | Javascript, sweetened.

< All Posts

v1.2.4 - Big speed boost on arrays

March 26, 2012

Changelog | Cautionlog

The major change in this version is a big speed improvement for Array#unique, which now is an O(n) operation instead of O(n²). This method is also used internally in Array#union, Array#intersect, Array#min, Array#max, Array#most, and Array#least, so all these methods benefit from this. Many thanks to @ermouth for pointing out the issue and helping explore ideas for the solution.

This change also prompted a big internal refactoring with Object.equal. Although the effective result is only visible in a few edge cases, it means that Object.equal is now effectively “egal”, meaning the two values are equal if they are “not observably distinguishable”. This now brings Sugar in line with Underscore’s _.isEqual. See here for more on the concept of “egal”.

A few other minor bugfixes also found their way in, including custom date formats that override built-in formats.


comments powered by Disqus