events: make eventNames() use Reflect.ownKeys()

Use `Reflect.ownKeys()` instead of `Object.keys()` and
`Object.getOwnPropertySymbols()`.

PR-URL: https://github.com/nodejs/node/pull/5822
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Luigi Pinca 2016-03-21 12:28:17 +01:00 committed by James M Snell
parent cdba9a6c02
commit c1cd64481f

View File

@ -437,12 +437,7 @@ function listenerCount(type) {
}
EventEmitter.prototype.eventNames = function eventNames() {
if (this._eventsCount > 0) {
const events = this._events;
return Object.keys(events).concat(
Object.getOwnPropertySymbols(events));
}
return [];
return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
};
// About 1.5x faster than the two-arg version of Array#splice().