Merge pull request #5643 from Tyriar/cacheWorkCell

Cache work cell in hot loops
This commit is contained in:
Daniel Imms
2026-01-31 10:33:25 -08:00
committed by GitHub
2 changed files with 6 additions and 5 deletions
+3 -1
View File
@@ -9,6 +9,8 @@ import { CellData } from 'common/buffer/CellData';
import { IBufferService, IOptionsService, IOscLinkService } from 'common/services/Services';
export class OscLinkProvider implements ILinkProvider {
private readonly _workCell = new CellData();
constructor(
@IBufferService private readonly _bufferService: IBufferService,
@IOptionsService private readonly _optionsService: IOptionsService,
@@ -25,7 +27,7 @@ export class OscLinkProvider implements ILinkProvider {
const result: ILink[] = [];
const linkHandler = this._optionsService.rawOptions.linkHandler;
const cell = new CellData();
const cell = this._workCell;
const lineLength = line.getTrimmedLength();
let currentLinkId = -1;
let currentStart = -1;
+3 -4
View File
@@ -39,6 +39,7 @@ export const DEFAULT_ATTR_DATA = Object.freeze(new AttributeData());
// Work variables to avoid garbage collection
let $startIndex = 0;
const $workCell = new CellData();
/** Factor when to cleanup underlying array buffer after shrinking. */
const CLEANUP_THRESHOLD = 2;
@@ -262,9 +263,8 @@ export class BufferLine implements IBufferLine {
}
if (n < this.length - pos) {
const cell = new CellData();
for (let i = this.length - pos - n - 1; i >= 0; --i) {
this.setCell(pos + n + i, this.loadCell(pos + i, cell));
this.setCell(pos + n + i, this.loadCell(pos + i, $workCell));
}
for (let i = 0; i < n; ++i) {
this.setCell(pos + i, fillCellData);
@@ -284,9 +284,8 @@ export class BufferLine implements IBufferLine {
public deleteCells(pos: number, n: number, fillCellData: ICellData): void {
pos %= this.length;
if (n < this.length - pos) {
const cell = new CellData();
for (let i = 0; i < this.length - pos - n; ++i) {
this.setCell(pos + i, this.loadCell(pos + n + i, cell));
this.setCell(pos + i, this.loadCell(pos + n + i, $workCell));
}
for (let i = this.length - n; i < this.length; ++i) {
this.setCell(i, fillCellData);