perf: keep room contour cache out of editor previews

Issue: #322
User-Visible: no
This commit is contained in:
Matysh
2026-08-27 13:11:03 +03:00
parent 298030d47e
commit 87ff906545
16 changed files with 41 additions and 28 deletions
+9 -3
View File
@@ -11600,14 +11600,20 @@ class HouseplanCard extends LitElement {
): number[][] | null {
const cutsKey = openCuts.map((cut) => cut.join(',')).join(';');
const key = `${space.id}|${this._cfgEpoch}|${roomId}|${cutsKey}`;
const cached = lruRead(this._innerContourCache, key);
if (cached.hit) return cached.value;
// Editor previews can replace room polygons without advancing the saved
// config epoch. Cache only the immutable View surface; otherwise a Resize
// drag would keep painting (and hit-testing) the pre-drag contour.
const cacheable = this._mode === 'view' && !this._rszPreview;
if (cacheable) {
const cached = lruRead(this._innerContourCache, key);
if (cached.hit) return cached.value;
}
const value = innerContourForRoom(
space.rooms, roomId, this._spaceWalls, openCuts,
this._wallKeyPitch, this._cellCm, this._gridPitch, NORM_W,
roomWalls,
);
lruWrite(this._innerContourCache, key, value, 600);
if (cacheable) lruWrite(this._innerContourCache, key, value, 600);
return value;
}