Avoid spread when merging decoration line buckets
Replace existing.push(...bucket) with an indexed loop in _mergeLineBucket to avoid intermediate array allocations during buffer trim/insert/delete re-indexing. Reuse _mergeLineBucket in _handleBufferLinesTrim for consistency. Fixes #5941 Co-authored-by: Daniel Imms <Tyriar@users.noreply.github.com>
This commit is contained in:
co-authored by
Daniel Imms
parent
2ab0f10a26
commit
41dfdba2cf
@@ -225,12 +225,7 @@ export class DecorationLineCache extends Disposable {
|
||||
if (newLine < 0) {
|
||||
continue;
|
||||
}
|
||||
const existing = newMap.get(newLine);
|
||||
if (existing) {
|
||||
existing.push(...bucket);
|
||||
} else {
|
||||
newMap.set(newLine, bucket.slice());
|
||||
}
|
||||
this._mergeLineBucket(newMap, newLine, bucket);
|
||||
}
|
||||
this._decorationsByLine.clear();
|
||||
for (const [line, bucket] of newMap) {
|
||||
@@ -254,7 +249,9 @@ export class DecorationLineCache extends Disposable {
|
||||
private _mergeLineBucket(newMap: Map<number, IInternalDecoration[]>, line: number, bucket: IInternalDecoration[]): void {
|
||||
const existing = newMap.get(line);
|
||||
if (existing) {
|
||||
existing.push(...bucket);
|
||||
for (let i = 0, len = bucket.length; i < len; i++) {
|
||||
existing.push(bucket[i]);
|
||||
}
|
||||
} else {
|
||||
newMap.set(line, bucket.slice());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user