{"action":"created","issue":{"url":"https://api.github.com/repos/caolan/highland/issues/395","labels_url":"https://api.github.com/repos/caolan/highland/issues/395/labels{/name}","comments_url":"https://api.github.com/repos/caolan/highland/issues/395/comments","events_url":"https://api.github.com/repos/caolan/highland/issues/395/events","html_url":"https://github.com/caolan/highland/pull/395","id":117699289,"number":395,"title":"Use Set in uniq() When Available In Environment","user":{"login":"svozza","id":8573472,"avatar_url":"https://avatars.githubusercontent.com/u/8573472?v=3","gravatar_id":"","url":"https://api.github.com/users/svozza","html_url":"https://github.com/svozza","followers_url":"https://api.github.com/users/svozza/followers","following_url":"https://api.github.com/users/svozza/following{/other_user}","gists_url":"https://api.github.com/users/svozza/gists{/gist_id}","starred_url":"https://api.github.com/users/svozza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svozza/subscriptions","organizations_url":"https://api.github.com/users/svozza/orgs","repos_url":"https://api.github.com/users/svozza/repos","events_url":"https://api.github.com/users/svozza/events{/privacy}","received_events_url":"https://api.github.com/users/svozza/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/caolan/highland/milestones/2","html_url":"https://github.com/caolan/highland/milestones/v2.6.0","labels_url":"https://api.github.com/repos/caolan/highland/milestones/2/labels","id":1127912,"number":2,"title":"v2.6.0","description":"","creator":{"login":"vqvu","id":6435429,"avatar_url":"https://avatars.githubusercontent.com/u/6435429?v=3","gravatar_id":"","url":"https://api.github.com/users/vqvu","html_url":"https://github.com/vqvu","followers_url":"https://api.github.com/users/vqvu/followers","following_url":"https://api.github.com/users/vqvu/following{/other_user}","gists_url":"https://api.github.com/users/vqvu/gists{/gist_id}","starred_url":"https://api.github.com/users/vqvu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vqvu/subscriptions","organizations_url":"https://api.github.com/users/vqvu/orgs","repos_url":"https://api.github.com/users/vqvu/repos","events_url":"https://api.github.com/users/vqvu/events{/privacy}","received_events_url":"https://api.github.com/users/vqvu/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":27,"state":"open","created_at":"2015-05-25T03:18:52Z","updated_at":"2015-11-18T23:18:48Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2015-11-18T22:42:59Z","updated_at":"2015-11-19T00:23:17Z","closed_at":"2015-11-18T23:18:48Z","pull_request":{"url":"https://api.github.com/repos/caolan/highland/pulls/395","html_url":"https://github.com/caolan/highland/pull/395","diff_url":"https://github.com/caolan/highland/pull/395.diff","patch_url":"https://github.com/caolan/highland/pull/395.patch"},"body":"A recent discussion on Ramda (ramda/ramda#1512) prompted me to have a look at our `uniq` function so I ported over the benchmarks from there and ran them against our code base. The results were not pretty:\r\n\r\n>.uniq x 10,000 (heterogenous)\r\n\r\n>underscore  ######################### 61ms\r\nlodash      #### 8ms\r\nhighland    ############################################################ 151ms\r\n\r\n>.uniq x 10,000 (numbers)\r\n\r\n>underscore  ############################## 5ms\r\nlodash      ############ 2ms\r\nhighland    ############################################################ 10ms\r\n\r\n>.uniq x 10,000 (all unique)\r\n\r\n>underscore  #################### 316ms\r\nlodash      # 8ms\r\nhighland    ############################################################ 966ms\r\n\r\nHowever, by using `Set` when it is available in the environment the performance can be improved dramatically.\r\n\r\n>.uniq x 10,000 (heterogenous)\r\n\r\n>underscore  ############################################################ 68ms\r\nlodash      ######## 8ms\r\nhighland    ##### 5ms\r\n\r\n>.uniq x 10,000 (numbers)\r\n\r\n>underscore  ############################################################ 5ms\r\nlodash      ############ 1ms\r\nhighland    #################################### 3ms\r\n\r\n>.uniq x 10,000 (all unique)\r\n\r\n>underscore  ############################################################ 329ms\r\nlodash      ## 8ms\r\nhighland    ## 6ms\r\n\r\nI normally shy away from this sort of feature sniffing but this is such an easy gain that will benefit all our users running Node 0.12, 4.x and 5.x that I think it's worth it in this case. Thoughts?"},"comment":{"url":"https://api.github.com/repos/caolan/highland/issues/comments/157907557","html_url":"https://github.com/caolan/highland/pull/395#issuecomment-157907557","issue_url":"https://api.github.com/repos/caolan/highland/issues/395","id":157907557,"user":{"login":"vqvu","id":6435429,"avatar_url":"https://avatars.githubusercontent.com/u/6435429?v=3","gravatar_id":"","url":"https://api.github.com/users/vqvu","html_url":"https://github.com/vqvu","followers_url":"https://api.github.com/users/vqvu/followers","following_url":"https://api.github.com/users/vqvu/following{/other_user}","gists_url":"https://api.github.com/users/vqvu/gists{/gist_id}","starred_url":"https://api.github.com/users/vqvu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vqvu/subscriptions","organizations_url":"https://api.github.com/users/vqvu/orgs","repos_url":"https://api.github.com/users/vqvu/repos","events_url":"https://api.github.com/users/vqvu/events{/privacy}","received_events_url":"https://api.github.com/users/vqvu/received_events","type":"User","site_admin":false},"created_at":"2015-11-19T00:23:17Z","updated_at":"2015-11-19T00:23:17Z","body":"Something just occurred to me. Equality in sets is not the same as `===` (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set). So the current implementation will behave differently on different Nodes.\r\n\r\nSpecifically, Set uses [SameValueZero](http://www.ecma-international.org/ecma-262/6.0/#sec-samevaluezero), which is different from [StrictEqualityComparison](http://www.ecma-international.org/ecma-262/6.0/#sec-strict-equality-comparison). Although the only difference is that `NaN !== NaN`, while `SameValueZero(NaN, NaN) === true`.\r\n\r\nWe need to check for `NaN` in the Set implementation and always pass it through.\r\n\r\nAlso, I personally don't think `NaN === NaN` is intuitive despite IEEE's opinion on the matter. Should we switch to using `SameValueZero` for the equality algorithm in 3.0.0?\r\n\r\nFor comparison\r\n\r\n- lodash [uses SameValueZero](https://lodash.com/docs#uniq)\r\n- underscore [uses StrictEqualityComparison](http://underscorejs.org/#uniq)\r\n- rambda [uses their own value equality implementation](http://ramdajs.com/docs/#uniq)"}}