Use two interations instead of while loop for trimming log
FREEBIE
This commit is contained in:
parent
53d1e7e6c7
commit
e4ceb21002
1 changed files with 8 additions and 2 deletions
|
@ -33,8 +33,14 @@
|
||||||
entry.save();
|
entry.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (this.length > MAX_MESSAGES) {
|
// Two separate iterations to deal with removal eventing wonkiness
|
||||||
this.at(0).destroy();
|
var toDrop = this.length - MAX_MESSAGES;
|
||||||
|
var entries = [];
|
||||||
|
for (var i = 0; i < toDrop; i += 1) {
|
||||||
|
entries.push(this.at(i));
|
||||||
|
}
|
||||||
|
for (var j = 0, max = entries.length; j < max; j += 1) {
|
||||||
|
entries[i].destroy();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
print: function() {
|
print: function() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue