Avoid Function#apply() for performance.

This commit is contained in:
Julien Fontanet 2015-04-08 10:50:04 +02:00
parent 6c83308451
commit 5e0c4d7b7a

View File

@ -128,7 +128,7 @@ export default class Collection extends EventEmitter {
} }
add (keyOrObjectWithId, valueIfKey = null) { add (keyOrObjectWithId, valueIfKey = null) {
const [key, value] = this._resolveEntry.apply(this, arguments) const [key, value] = this._resolveEntry(keyOrObjectWithId, valueIfKey)
this._assertHasNot(key) this._assertHasNot(key)
this._map[key] = value this._map[key] = value
@ -139,7 +139,7 @@ export default class Collection extends EventEmitter {
} }
set (keyOrObjectWithId, valueIfKey = null) { set (keyOrObjectWithId, valueIfKey = null) {
const [key, value] = this._resolveEntry.apply(this, arguments) const [key, value] = this._resolveEntry(keyOrObjectWithId, valueIfKey)
const action = this.has(key) ? 'update' : 'add' const action = this.has(key) ? 'update' : 'add'
this._map[key] = value this._map[key] = value
@ -165,7 +165,7 @@ export default class Collection extends EventEmitter {
} }
update (keyOrObjectWithId, valueIfKey = null) { update (keyOrObjectWithId, valueIfKey = null) {
const [key, value] = this._resolveEntry.apply(this, arguments) const [key, value] = this._resolveEntry(keyOrObjectWithId, valueIfKey)
this._assertHas(key) this._assertHas(key)
this._map[key] = value this._map[key] = value