-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
EventEmitter: use a Map to store event listeners #1785
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
exports.EEEvents = Symbol('EventEmitter events'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2925,9 +2925,6 @@ void SetupProcessObject(Environment* env, | |
env->SetMethod(process, "_setupNextTick", SetupNextTick); | ||
env->SetMethod(process, "_setupPromises", SetupPromises); | ||
env->SetMethod(process, "_setupDomainUse", SetupDomainUse); | ||
|
||
// pre-set _events object for faster emit checks | ||
process->Set(env->events_string(), Object::New(env->isolate())); | ||
} | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this necessary? Isn't there a way to create a Map from C++? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe. I couldn't find anything related to maps in the v8 API and I know that the Map constructor is written in JS but there may be a way to call it from C++ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will be possible with v8 4.5: v8/v8@395fa8b |
||
|
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.
I'm curious about performance differences with this particular change. Is it faster to keep
_eventsCount
around and create a new Map()?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.
There is no significant performance difference if I revert ca75072. I tested with
this._events.clear()
andthis._events = new Map()