Skip to content

Commit ec6f3d5

Browse files
committed
simplify dropping older items
1 parent 3f40996 commit ec6f3d5

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

packages/sds/src/message_channel/mem_local_history.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,8 @@ export class MemLocalHistory {
4848

4949
// Let's drop older messages if max length is reached
5050
if (this.length > this.maxLength) {
51-
// TODO: Would it be faster to reverse, pop, reverse?
5251
const numItemsToRemove = this.length - this.maxLength;
53-
const timestampCutoff = this.items[numItemsToRemove - 1].lamportTimestamp;
54-
this.items = this.items.filter(
55-
(m) => m.lamportTimestamp > timestampCutoff
56-
);
52+
this.items.splice(0, numItemsToRemove);
5753
}
5854

5955
return this.items.length;

0 commit comments

Comments
 (0)