-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
src: use unordered_set
instead of custom rb tree
#14826
Conversation
Use a standard hash-based container instead of the custom included red/black tree implementation. There is likely no noticeable performance difference, and if there is one, it is very likely to be an improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a suggestion.
src/cares_wrap.cc
Outdated
} | ||
}; | ||
|
||
typedef std::unordered_set<node_ares_task*, TaskHash, TaskEqual> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use using ... = ...
, it's a little shorter.
As well, you could replace TaskHash with a simple using TaskHash = std::hash<node_ares_task*>;
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use
using ... = ...
, it's a little shorter.
Done. :)
As well, you could replace TaskHash with a simple
using TaskHash = std::hash<node_ares_task*>;
, right?
That would make the hash set believe that any two different node_ares_task*
pointers refer to different entries, but that’s not how we use it in the lookup below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry, I missed that I hadn’t pushed the right code for TaskHash
yet. Now it’s more obvious why that doesn’t work. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, that clears it up. Thanks, LGTM.
@@ -887,8 +887,6 @@ jslint-ci: | |||
|
|||
CPPLINT_EXCLUDE ?= | |||
CPPLINT_EXCLUDE += src/node_root_certs.h | |||
CPPLINT_EXCLUDE += src/queue.h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a standard hash-based container instead of the custom included red/black tree implementation. There is likely no noticeable performance difference, and if there is one, it is very likely to be an improvement. PR-URL: nodejs#14826 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Use a standard hash-based container instead of the custom included red/black tree implementation. There is likely no noticeable performance difference, and if there is one, it is very likely to be an improvement. PR-URL: #14826 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Use a standard hash-based container instead of the custom included red/black tree implementation. There is likely no noticeable performance difference, and if there is one, it is very likely to be an improvement. PR-URL: #14826 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Use a standard hash-based container instead of the custom included red/black tree implementation. There is likely no noticeable performance difference, and if there is one, it is very likely to be an improvement. PR-URL: #14826 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Should this be backported to |
Use a standard hash-based container instead of the custom included
red/black tree implementation. There is likely no noticeable
performance difference, and if there is one, it is very likely
to be an improvement.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
src/cares_wrap