浏览代码

Fixes mru history truncation

main
Eric Amodio 1年前
父节点
当前提交
bdbab69ab9
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. +4
    -4
      src/system/mru.ts

+ 4
- 4
src/system/mru.ts 查看文件

@ -1,7 +1,7 @@
export class MRU<T> {
private stack: T[] = [];
constructor(public readonly maxSize: number = 10, private readonly compare?: (a: T, b: T) => boolean) {}
constructor(public readonly maxSize: number = 10, private readonly comparator?: (a: T, b: T) => boolean) {}
get count(): number {
return this.stack.length;
@ -14,10 +14,10 @@ export class MRU {
add(item: T): void {
const index =
this.compare != null ? this.stack.findIndex(i => this.compare!(item, i)) : this.stack.indexOf(item);
this.comparator != null ? this.stack.findIndex(i => this.comparator!(item, i)) : this.stack.indexOf(item);
if (this._position != null && this._position > 0) {
this.stack = this.stackpan>.slice(0, this._position + 1);
if (this._position > 0) {
this.stack.splice(0, this._position);
this._position = 0;
}

正在加载...
取消
保存