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

Simplification of memoize given no hasher #1679

Merged
merged 1 commit into from
Jun 13, 2014

Conversation

megawac
Copy link
Collaborator

@megawac megawac commented Jun 13, 2014

Simplifies the expected case for _.memoize

@davidchambers
Copy link
Contributor

LGTM

var cache = memoize.cache;
var key = hasher.apply(this, arguments);
if (hasher) key = hasher.apply(this, arguments);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're gonna run into issues because changing the value of key will change the value in the arguments object too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! What a strange language "feature"!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot about that, I'll address that and add a spec

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya, it bit when I tried to simplify this method before, which is why I knew to look for it :P

also specs the case mentioned by @jdalton in comments (great catch!)
michaelficarra added a commit that referenced this pull request Jun 13, 2014
Simplification of memoize given no hasher
@michaelficarra michaelficarra merged commit e39bea5 into jashkenas:master Jun 13, 2014
@megawac megawac deleted the memoize branch June 16, 2014 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants