Skip to content

Commit aca2668

Browse files
committed
debt - put MovingAverage to numbers
1 parent 20f06ed commit aca2668

2 files changed

Lines changed: 17 additions & 14 deletions

File tree

src/vs/base/common/numbers.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,19 @@ export class Counter {
1818
return this._next++;
1919
}
2020
}
21+
22+
export class MovingAverage {
23+
24+
private _n = 1;
25+
private _val = 0;
26+
27+
update(value: number): this {
28+
this._val = this._val + (value - this._val) / this._n;
29+
this._n += 1;
30+
return this;
31+
}
32+
33+
get value(): number {
34+
return this._val;
35+
}
36+
}

src/vs/editor/contrib/documentSymbols/outlineModel.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { ITextModel } from 'vs/editor/common/model';
1414
import { DocumentSymbol, DocumentSymbolProvider, DocumentSymbolProviderRegistry } from 'vs/editor/common/modes';
1515
import { MarkerSeverity } from 'vs/platform/markers/common/markers';
1616
import { Iterable } from 'vs/base/common/iterator';
17+
import { MovingAverage } from 'vs/base/common/numbers';
1718

1819
export abstract class TreeElement {
1920

@@ -202,21 +203,7 @@ export class OutlineGroup extends TreeElement {
202203
}
203204
}
204205

205-
class MovingAverage {
206206

207-
private _n = 1;
208-
private _val = 0;
209-
210-
update(value: number): this {
211-
this._val = this._val + (value - this._val) / this._n;
212-
this._n += 1;
213-
return this;
214-
}
215-
216-
get value(): number {
217-
return this._val;
218-
}
219-
}
220207

221208
export class OutlineModel extends TreeElement {
222209

0 commit comments

Comments
 (0)