Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Faster(1.5 - 34 times) Array.unique speed. #1084

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
2 participants
Owner

arian commented Dec 19, 2011

You're storing the values in an object, with the values as keys. Doing that will call valueOf() of each value. When the values are strings or numbers it's ok, however with other objects this probably won't work.

Also could you provide some http://jsperf.com

cainrus commented Dec 20, 2011

Updated. Tests: http://jsperf.com/mootools-array-uniq-vs-vanilla/2
Please check it. Do we need sugar or speed in core code? Need a framework for micro optimizations?

Owner

arian commented Dec 20, 2011

Very nice, however the cases I tried to explain, still don't work, see http://jsfiddle.net/EJX8n/ with your code and http://jsfiddle.net/EJX8n/1/ with the current code.

Faster is better, but what's more important is readability and API. Especially with these JS functions, which are usually not the bottleneck in your application (compared to DOM stuff).

cainrus commented Dec 20, 2011

agree

@cainrus cainrus closed this Dec 20, 2011

Owner

arian commented Dec 20, 2011

Thanks for your effort though, much appreciated! If you see other possible improvements, please let us know :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment