Created
December 11, 2020 14:11
-
-
Save smpnjn/314ed43509e920bcf4b3046ae14891b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// current approach | |
old = map.get(key); | |
if (!old) { | |
map.set(key, value); | |
} else { | |
map.set(key, updated); | |
} | |
// new approach | |
map.emplace(key, { | |
update: () => updated, | |
insert: () => value | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment