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

Refine _.pick #2065

Merged
merged 1 commit into from
Feb 20, 2015
Merged

Refine _.pick #2065

merged 1 commit into from
Feb 20, 2015

Conversation

jridgewell
Copy link
Collaborator

Not sure how this’ll do performance wise. I’ll write a jsperf tomorrow.

@megawac
Copy link
Collaborator

megawac commented Feb 20, 2015

Any advantage to this refactor? Did _.pick({constructor: 1}, 'constructor') not work or something? (thought 173a7fa fixed this)

@jridgewell
Copy link
Collaborator Author

It was a lot of duplicated code between the two branches to support an inline key in obj.

173a7fa fixed issues with adding new keys as you're iterating, but it created linting errors (duplicate var declarations).


I think this wraps up all the removals changes from 1.8 to 1.8.1. I can't spell anymore, time for bed. 😴

@megawac
Copy link
Collaborator

megawac commented Feb 20, 2015

I tried a similar refactor before for reference #1639. Had heavy perf hits for the keys case

@jridgewell
Copy link
Collaborator Author

That's probably because of Line 903. The only perf hit this should take is invoking (and this is sure to be inlined) in the _.pick(obj, 'key', 'key2') case.

var iteratee = function(value, key, object) {
  return key in object;
};

jashkenas added a commit that referenced this pull request Feb 20, 2015
@jashkenas jashkenas merged commit 053e468 into jashkenas:master Feb 20, 2015
@megawac
Copy link
Collaborator

megawac commented Feb 20, 2015

Can you post benchmarks when you get a chance
On Feb 20, 2015 1:06 AM, "Jeremy Ashkenas" notifications@github.com wrote:

Merged #2065 #2065.


Reply to this email directly or view it on GitHub
#2065 (comment).

@jridgewell
Copy link
Collaborator Author

jsperf.

Unfortunately, it's a bit slower for the _.pick(obj, 'key') case. I was able to improve performance a bit in an opt branch.

@jashkenas
Copy link
Owner

That's a weird optimization, no?

@jridgewell
Copy link
Collaborator Author

Are you talking about #2068?

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

Successfully merging this pull request may close these issues.

3 participants