Skip to content

Share computed point keys across preview, editing and stats (#11) - #12

Merged
YurMil merged 1 commit into
mainfrom
perf/share-point-keys
Jul 17, 2026
Merged

Share computed point keys across preview, editing and stats (#11)#12
YurMil merged 1 commit into
mainfrom
perf/share-point-keys

Conversation

@YurMil

@YurMil YurMil commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Closes #11.

Compute tube-point string keys once per layout and share the result, instead of recomputing createPointKey over every point in three separate modules.

Change

  • New shared KeyedPoint type + keyPoints() helper in core.
  • App builds keyedTubes once (memoised on tubeCoords) and threads it into:
    • PreviewCanvas — now takes keyedPoints and drops its own key memo
    • useHoleEditing — builds pointByKey from the existing keys (no key pass)
    • computeTubeStats — consumes keyed points directly
  • DXF/STEP export paths keep computing keys where they run (rare / off-thread), unchanged.

Impact

A single key pass was ~9 ms at 52k points and previously ran ~3× per layout change (~27 ms on the main thread). This collapses it to one pass. Negligible for typical layouts (sub-ms), meaningful only near the point cap — the honest remaining hot spot from the earlier render investigation.

Verification

  • pnpm typecheck ✅ · pnpm test (58, computeTubeStats tests updated for keyed input) ✅ · pnpm build
  • In-browser: render, click-select, live stats, and a tie-rod edit (Active 168 / Tie rods 1 / area 39.584 m²) all correct through the shared-keys path; no error boundary.

🤖 Generated with Claude Code

Compute point string keys once per layout (App-level keyPoints) and thread the
KeyedPoint[] into the preview, useHoleEditing and computeTubeStats, instead of
each recomputing createPointKey over every point. On dense layouts that
removes ~2/3 of the per-layout key work (a full pass was ~9ms at 52k points).

- add shared KeyedPoint type + keyPoints() helper in core
- PreviewCanvas takes keyedPoints (drops its internal key memo)
- useHoleEditing builds pointByKey from existing keys
- computeTubeStats consumes keyed points (tests updated)

No behaviour change; verified in-browser (render, select, stats, tie-rod edit).
Closes #11.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@YurMil
YurMil merged commit 0994bbe into main Jul 17, 2026
2 checks passed
@YurMil
YurMil deleted the perf/share-point-keys branch July 17, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Share computed point keys across preview, editing and stats

1 participant