Skip to content

Instantly share code, notes, and snippets.

@smpnjn
Created December 11, 2020 14:11
Show Gist options
  • Save smpnjn/314ed43509e920bcf4b3046ae14891b9 to your computer and use it in GitHub Desktop.
Save smpnjn/314ed43509e920bcf4b3046ae14891b9 to your computer and use it in GitHub Desktop.
// 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