events: handle inherited properties properly#2350
events: handle inherited properties properly#2350thefourtheye wants to merge 1 commit intonodejs:masterfrom
Conversation
|
Oh. Performance hit. Okay, how about using a |
|
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?
|
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-majorchange, as this could be a breaking change.