Uh oh!
There was an error while loading. Please reload this page.
events: handle inherited properties properly - #2350
Conversation
vkurchatkin
commented
Aug 11, 2015
thefourtheye
commented
Aug 11, 2015
Oh. Performance hit. Okay, how about using a |
vkurchatkin
commented
Aug 11, 2015
brendanashworth
commented
Aug 13, 2015
Could someone run benchmarks on the entire
This doesn't seem to be benchmarking much, |
There was a problem hiding this comment.
Is this a necessary change?
thefourtheye
commented
Aug 15, 2015
Closing in favour of #1785 |
thefourtheye
commented
Nov 15, 2015
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')
1a18b67e to
85b2939Comparemscdex
commented
Nov 16, 2015
@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: |
targos
commented
Nov 16, 2015
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. |
targos
commented
Nov 16, 2015
@thefourtheye can you compare the EE benchmarks between master and master + this PR ? |
mscdex
commented
Nov 16, 2015
@targos I just added code that interacts with |
jasnell
commented
Mar 22, 2016
@thefourtheye ... is this still something you want to pursue? |
thefourtheye
commented
Mar 25, 2016
@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-majorchange, as this could be a breaking change.