perf(panel): optimize P1 hot paths and consolidate P2 shared primitives

This commit is contained in:
fish
2026-11-23 16:21:39 +09:00
parent 3a40bacc9d
commit 424ac73489
48 changed files with 4040 additions and 2745 deletions
@@ -57,6 +57,7 @@ export function writeTrajectoryCacheFile(filePath, data) {
append('}');
const temporaryPath = `${filePath}.${randomUUID()}.tmp`;
let renamed = false;
try {
const fd = openSync(temporaryPath, 'wx');
try {
@@ -72,6 +73,7 @@ export function writeTrajectoryCacheFile(filePath, data) {
}
const written = statSync(temporaryPath, { bigint: true });
renameSync(temporaryPath, filePath);
renamed = true;
const file = statSync(filePath, { bigint: true });
lastWritesByPath.delete(filePath);
if (isSameFile(written, file)) {
@@ -82,6 +84,8 @@ export function writeTrajectoryCacheFile(filePath, data) {
lastWritesByPath.set(filePath, { filePath, file, ranges });
}
} finally {
try { unlinkSync(temporaryPath); } catch {}
if (!renamed) {
try { unlinkSync(temporaryPath); } catch {}
}
}
}