Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(web): terminal snapshots reuse WASM memory views #26717

Mergedhieu-lee(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/26717/headmerged by maria-rcks View on GitHub

Showing 2 changed files with 55 additions and 37 deletions.

x
0 of 2 viewed, 2 left
33 additions and 32 deletionsapps/web/src/terminal/ghostty/core.tsModified
View file
@@ -177,15 +177,19 @@
​
/** Bounds String.fromCodePoint arguments for cells with enormous combining-mark sequences. */
-export function ghosttyCellText(codepointView: DataView, graphemeLength: number): string {
- if (graphemeLength === 1) return String.fromCodePoint(codepointView.getUint32(0, true));
+export function ghosttyCellText(
+ codepointView: DataView,
+ graphemeLength: number,
+ byteOffset = 0,
+): string {
+ if (graphemeLength === 1) return String.fromCodePoint(codepointView.getUint32(byteOffset, true));
const CHUNK_SIZE = 4_096;
let text = "";
for (let start = 0; start < graphemeLength; start += CHUNK_SIZE) {
const count = Math.min(CHUNK_SIZE, graphemeLength - start);
const codes = new Array<number>(count);
for (let index = 0; index < count; index += 1) {
- codes[index] = codepointView.getUint32((start + index) * 4, true);
+ codes[index] = codepointView.getUint32(byteOffset + (start + index) * 4, true);
text += String.fromCodePoint(...codes);
@@ -834,12 +838,12 @@
if (rowDirty) {
this.rows[rowIndex] = this.readRow(iterator, cols, foreground, background);
dirtyRows.add(rowIndex);
- this.runtime.bytes(this.scratch, 1)[0] = 0;
+ this.runtime.memoryBytes()[this.scratch] = 0;