Skip to content

Commit

Permalink
Merge pull request #1900 from Tyriar/cleanup
Browse files Browse the repository at this point in the history
Remove unused var and unneeded defensive check
  • Loading branch information
Tyriar committed Jan 27, 2019
2 parents c908da3 + 3a32a57 commit 51a1485
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
1 change: 0 additions & 1 deletion demo/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* This file is the entry point for browserify.
*/

const cp = require('child_process');
const path = require('path');
const webpack = require('webpack');
const startServer = require('./server.js');
Expand Down
32 changes: 15 additions & 17 deletions src/common/CircularList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,24 +154,22 @@ export class CircularList<T> extends EventEmitter implements ICircularList<T> {
this._length -= deleteCount;
}

if (items && items.length) {
// Add items
for (let i = this._length - 1; i >= start; i--) {
this._array[this._getCyclicIndex(i + items.length)] = this._array[this._getCyclicIndex(i)];
}
for (let i = 0; i < items.length; i++) {
this._array[this._getCyclicIndex(start + i)] = items[i];
}
// Add items
for (let i = this._length - 1; i >= start; i--) {
this._array[this._getCyclicIndex(i + items.length)] = this._array[this._getCyclicIndex(i)];
}
for (let i = 0; i < items.length; i++) {
this._array[this._getCyclicIndex(start + i)] = items[i];
}

// Adjust length as needed
if (this._length + items.length > this._maxLength) {
const countToTrim = (this._length + items.length) - this._maxLength;
this._startIndex += countToTrim;
this._length = this._maxLength;
this.emitMayRemoveListeners('trim', countToTrim);
} else {
this._length += items.length;
}
// Adjust length as needed
if (this._length + items.length > this._maxLength) {
const countToTrim = (this._length + items.length) - this._maxLength;
this._startIndex += countToTrim;
this._length = this._maxLength;
this.emitMayRemoveListeners('trim', countToTrim);
} else {
this._length += items.length;
}
}

Expand Down

0 comments on commit 51a1485

Please sign in to comment.