-
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
events: handle inherited properties properly #2350
events: handle inherited properties properly #2350
Conversation
Oh. Performance hit. Okay, how about using a |
Could someone run benchmarks on the entire
This doesn't seem to be benchmarking much, |
@@ -23,7 +23,7 @@ assert(fl.length === 1); | |||
assert(fl[0] === assert.fail); | |||
|
|||
e.listeners('bar'); | |||
assert(!e._events.hasOwnProperty('bar')); | |||
assert(!e._events['bar']); |
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.
Is this a necessary change?
Closing in favour of #1785 |
Reopening this thread as #1785 was shot down and |
As of now, the events module considers inherited properties as one of the valid types, by default. > process.version 'v3.0.0' > events.EventEmitter.listenerCount(new events.EventEmitter(), 'toString') 1 This patch makes sure that the inherited properties are considered as normal types and they will not be counted unless explicitly added. > process.version 'v4.0.0-pre' > events.EventEmitter.listenerCount(new events.EventEmitter(), 'toString') 0 > const emitter = new events.EventEmitter(); undefined > emitter.on('toString', function() {}); EventEmitter { domain: Domain { domain: null, _events: { error: [Function] }, _eventsCount: 1, _maxListeners: undefined, members: [] }, _events: { toString: [Function] }, _eventsCount: 1, _maxListeners: undefined } > events.EventEmitter.listenerCount(emitter, 'toString') 1
a18b67e
to
85b2939
Compare
@thefourtheye I'm not seeing the same results that you described in that other issue. Here is what I get with current master and your benchmark script:
|
I'm seeing the same kind of benchmark results but I'm not sure we can trust them. V8 may be smart enough to see that we don't do anything with the object literal and not create it at all. |
@thefourtheye can you compare the EE benchmarks between master and master + this PR ? |
@targos I just added code that interacts with |
@thefourtheye ... is this still something you want to pursue? |
@jasnell Yes, as this has to be fixed somehow. I'll close this now and open a separate PR. |
As of now, the events module considers inherited properties as one of the
valid types, by default.
This patch makes sure that the inherited properties are considered as
normal types and they will not be counted unless explicitly added.
I am guessing this would be a
semver-major
change, as this could be a breaking change.