Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upurl: use SafeSet to filter known special protocols #24703
Conversation
nodejs-github-bot
added
the
url
label
Nov 28, 2018
This comment has been minimized.
This comment has been minimized.
|
can they just be changed to maps? |
This comment has been minimized.
This comment has been minimized.
|
@devsnek, They could be changed to Sets. There's no need to lookup a value. Would you prefer that? |
This comment has been minimized.
This comment has been minimized.
|
@mikesamuel i would definitely prefer using sets |
This comment has been minimized.
This comment has been minimized.
|
This seems to make the code harder to understand. We usually just go with |
This comment has been minimized.
This comment has been minimized.
|
I think the reason to no use null prototype objects was lookup performance. I don't know if it's still faster. |
This comment has been minimized.
This comment has been minimized.
|
Reworking to use sets. @lpinca, Re performance, https://github.com/anvaka/set-vs-object#conclusion is one microbenchmark. |
mikesamuel
force-pushed the
mikesamuel:patch-1
branch
from
68d69d1
to
479068b
Nov 28, 2018
This comment has been minimized.
This comment has been minimized.
|
I changed it to use SafeSet (thanks @joyeecheung), squashed the commits, and changed the PR description to reflect that. |
This comment has been minimized.
This comment has been minimized.
|
I think my squash broke Travis's first commit message check :( |
This comment has been minimized.
This comment has been minimized.
|
@mikesamuel Can you update the commit message to something that describes the current approach? (e.g. something like |
mikesamuel
force-pushed the
mikesamuel:patch-1
branch
from
479068b
to
87677a9
Nov 29, 2018
This comment has been minimized.
This comment has been minimized.
|
@joyeecheung, done |
mikesamuel
changed the title
url: prototypes are not useful in lookup tables
url: use SafeSet to filter known special protocols
Nov 29, 2018
joyeecheung
approved these changes
Nov 29, 2018
This comment has been minimized.
This comment has been minimized.
cjihrig
approved these changes
Nov 29, 2018
jasnell
approved these changes
Nov 30, 2018
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Trott
added
the
author ready
label
Dec 1, 2018
This comment has been minimized.
This comment has been minimized.
|
(Benchmark tradeoffs look perfectly acceptable to me, but second opinion welcome.) |
This comment has been minimized.
This comment has been minimized.
|
Resume Build CI: https://ci.nodejs.org/job/node-test-pull-request/19114/ |
Trott
added a commit
to Trott/io.js
that referenced
this pull request
Dec 1, 2018
This comment has been minimized.
This comment has been minimized.
|
Landed in 0d23118. Thanks for the contribution! |
Trott
closed this
Dec 1, 2018
This comment has been minimized.
This comment has been minimized.
|
Post-mortem: benchmark results. The most significant ones (with Benchmark results
Significant impact
|
mikesamuel commentedNov 28, 2018
•
edited
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAvoids a maintenance hazard when reviewers assume that
hostlessProtocolandslashedProtocolare disjoint.The following may be counter-intuitive:
This change uses SafeSet instead of plain-old objects.
Rejected alternative:
We could have used object with a
nullprototype as lookup tablesso that
lowerProtois never treated as a key intoObject.prototype.