Skip to content

Commit

Permalink
do away with dynamic default value, #140557
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Jan 14, 2022
1 parent 8a928f9 commit 2e7075d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
19 changes: 4 additions & 15 deletions src/vs/editor/common/services/languageFeatureDebounce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class FeatureDebounceInformation implements IFeatureDebounceInformation {

constructor(
private readonly _registry: LanguageFeatureRegistry<object>,
private readonly _default: () => number,
private readonly _default: number,
private readonly _min: number,
private readonly _max: number = Number.MAX_SAFE_INTEGER,
) { }
Expand Down Expand Up @@ -81,20 +81,9 @@ export class FeatureDebounceInformation implements IFeatureDebounceInformation {
return result.value;
}

private _inDefault = false;

default() {
if (this._inDefault) {
// avoid recursion
return this._min;
}
try {
this._inDefault = true;
const value = (this._overall() | 0) || this._default();
return clamp(value, this._min, this._max);
} finally {
this._inDefault = false;
}
const value = (this._overall() | 0) || this._default;
return clamp(value, this._min, this._max);
}
}

Expand All @@ -112,7 +101,7 @@ export class LanguageFeatureDebounceService implements ILanguageFeatureDebounceS
let info = this._data.get(key);
if (!info) {
info = new FeatureDebounceInformation(feature,
() => (this._overallAverage() | 0) || (min * 1.5), // default is overall default or derived from min-value
(this._overallAverage() | 0) || (min * 1.5), // default is overall default or derived from min-value
min
);
this._data.set(key, info);
Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/contrib/documentSymbols/outlineModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export class OutlineGroup extends TreeElement {

export class OutlineModel extends TreeElement {

private static readonly _requestDurations = new FeatureDebounceInformation(DocumentSymbolProviderRegistry, () => 350, 350); // todo@jrieken ADOPT debounce service
private static readonly _requestDurations = new FeatureDebounceInformation(DocumentSymbolProviderRegistry, 350, 350); // todo@jrieken ADOPT debounce service
private static readonly _requests = new LRUCache<string, { promiseCnt: number, source: CancellationTokenSource, promise: Promise<any>, model: OutlineModel | undefined }>(9, 0.75);
private static readonly _keys = new class {

Expand Down

0 comments on commit 2e7075d

Please sign in to comment.