slightly faster trimAndRecycle

This commit is contained in:
Jörg Breitbart
2018-10-22 21:12:51 +02:00
parent 82228ad891
commit 1585aba5b5
+1 -4
View File
@@ -119,10 +119,7 @@ export class CircularList<T> extends EventEmitter implements ICircularList<T> {
}
public trimAndRecycle(): T | undefined {
this._startIndex++;
if (this._startIndex === this._maxLength) {
this._startIndex = 0;
}
this._startIndex = ++this._startIndex % this._maxLength;
this.emit('trim', 1);
return this._array[this._getCyclicIndex(this._length - 1)];
}