Repository navigation
Conversation
Discussion around nodejs#6102 has explored the possibility that a Map based implementation may be better, but there are backwards compatibility concerns over changing the API. This commit adds and internal implementation of a Map proxy object that allows a Map instance to act like it is an ordinary dictionary object as much as possible. A benchmark is included to show the perf differences. This is a work in progress experiment that should not yet be landed.
Contributor
|
I suspect this is going to be slow because access to proxied properties is slow. I was thinking something like this instead: function wrap(map) {
map.prototype = new Proxy(map, handler);
return map;
}This way the map can be accessed as an object OR as an Map. The idea would be to encourage people to use the as-Map API and deprecate the as-Object API. |
Member
Author
|
Yep, it's pretty slow in comparison... Mixing the two like you suggest might be problematic. For instance, what happens if there is a header named "get" or "set". I'll play around with it but I'm not quite as optimistic. |
Contributor
|
Yes that was one of my concerns also, having "get" or "set" header names. |
Member
Author
|
(aside... I find it quite funny that the bot created a new label for something that doesn't actually exist officially yet... may want to fix that ... /cc @Fishrock123 ) |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
make -j4 test(UNIX), orvcbuild test nosign(Windows) passesAffected core subsystem(s)
internal
Description of change
Discussion around #6102 has explored the
possibility that a Map based implementation may be better, but there are
backwards compatibility concerns over changing the API. This commit adds
and internal implementation of a Map proxy object that allows a Map instance
to act like it is an ordinary dictionary object as much as possible.
A benchmark is included to show the perf differences.
This is a work in progress experiment that should not yet be landed.
/cc @nodejs/ctc (@mscdex @ofrobots in particular)