Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve .unique to make use of es6 `Set` performance #185

Merged
merged 2 commits into from Apr 25, 2016
Merged

Conversation

@catalint
Copy link
Contributor

catalint commented Apr 5, 2016

@devinivy

This comment has been minimized.

Copy link
Member

devinivy commented Apr 5, 2016

It would be nice to add a test that differentiates the new behavior from the previous behavior (concerning the previous value coercion to string).

array.forEach((item) => {

const identifier = item[key];
if (!index.has(identifier)) {

This comment has been minimized.

Copy link
@nlf

nlf Apr 6, 2016

Member

i wonder if it would be more efficient to build the set without checking .has (since sets don't allow duplicate members anyway), and then returning Array.from(theSet) like we do below. building both a set and an array at the same time seems wasteful.

This comment has been minimized.

Copy link
@nlf

nlf Apr 6, 2016

Member

actually, scratch that, i just realized what this is actually doing

@catalint

This comment has been minimized.

Copy link
Contributor Author

catalint commented Apr 25, 2016

  • added more tests
  • also test results to be the same with previous version
  • added a new test for new support of unique array of object without key
@nlf nlf added the feature label Apr 25, 2016
@nlf nlf self-assigned this Apr 25, 2016
@nlf nlf added this to the 4.0.0 milestone Apr 25, 2016
@nlf nlf merged commit 5a2e384 into hapijs:master Apr 25, 2016
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.