From aca98b8a5e83df7cdf922fed4c6add0dc4036696 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Thu, 20 Aug 2026 16:32:14 +0200 Subject: [PATCH 1/2] silence noisy code for most trim events --- src/common/services/DecorationService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/services/DecorationService.ts b/src/common/services/DecorationService.ts index ea9b7fb14..49e85729d 100644 --- a/src/common/services/DecorationService.ts +++ b/src/common/services/DecorationService.ts @@ -214,7 +214,7 @@ export class DecorationLineCache extends Disposable { } private _handleBufferLinesTrim(amount: number): void { - if (amount <= 0) { + if (amount <= 0 || !this._decorationsByLine.size) { return; } const newMap = new Map(); From bc62843844b992700a26d4ba8536f94e0fb5cb6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Thu, 20 Aug 2026 16:32:41 +0200 Subject: [PATCH 2/2] optimize Event.fire --- src/common/Event.ts | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/common/Event.ts b/src/common/Event.ts index 88417fc83..9f7df4f9c 100644 --- a/src/common/Event.ts +++ b/src/common/Event.ts @@ -27,11 +27,13 @@ export class Emitter { } const entry = { fn: listener, thisArgs }; + this._listeners = this._listeners.slice(); this._listeners.push(entry); const result = toDisposable(() => { const idx = this._listeners.indexOf(entry); if (idx !== -1) { + this._listeners = this._listeners.slice(); this._listeners.splice(idx, 1); } }); @@ -50,23 +52,16 @@ export class Emitter { } public fire(event: T): void { - if (this._disposed) { + if (this._disposed || !this._listeners.length) { return; } - switch (this._listeners.length) { - case 0: return; - case 1: { - const { fn, thisArgs } = this._listeners[0]; - fn.call(thisArgs, event); - return; - } - default: { - // Snapshot listeners to allow modifications during iteration (2+ listeners) - const listeners = this._listeners.slice(); - for (const { fn, thisArgs } of listeners) { - fn.call(thisArgs, event); - } - } + if (this._listeners.length === 1) { + this._listeners[0].fn.call(this._listeners[0].thisArgs, event); + return; + } + const listeners = this._listeners; + for (let i = 0, len = listeners.length; i < len; ++i) { + listeners[i].fn.call(listeners[i].thisArgs, event); } }