Skip to content

return value on set#12

Open
jfromaniello wants to merge 1 commit into
dominictarr:masterfrom
jfromaniello:return_value_on_set
Open

return value on set#12
jfromaniello wants to merge 1 commit into
dominictarr:masterfrom
jfromaniello:return_value_on_set

Conversation

@jfromaniello

Copy link
Copy Markdown

This is handy because you can avoid an if statement, instead of doing

var value = lru.get('foo');
if (!value) {
 value = compute('foo');
 lru.set('foo', value);
}
...

You can do:

const value = lru.get('foo') || lru.set('foo', compute('foo'));
...

Some of the other LRU implementations on npm I have check implement this.

@davidmarkclements

Copy link
Copy Markdown
Collaborator

just to be absolutely sure - can we just make sure it doesn't affect the benchmarks in any significant way?

can you please run benchmarks for master and branch and post results?

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.

2 participants