Kraken’s nightly architectural scan flagged DiagramScreen.kt, claiming parseAnchors(content) (regex-based SVG anchor parsing) runs unbounded on every recomposition of DiagramScreen/MiniDiagram — implying O(N*M) CPU spikes during drag/zoom/layout interaction across “all diagram views.” The lead also cited parseAnchors as “not defined in the file” and flagged setSingletonImageLoaderFactory being called inside @Composable bodies as a reconfiguration hotspot.
Mostly a false positive, but it pointed at a real, narrower issue nearby.
parseAnchors is defined in the same file (DiagramScreen.kt, private top-level function) — the lead’s evidence for “not defined” was wrong, a sign the local-model review wasn’t reading the actual current file.parseAnchors(content) is inside a LaunchedEffect(meta.source) (or LaunchedEffect(node.id, meta.source)) success callback. LaunchedEffect only re-runs when its keys change, not on every recomposition — so the SVG is parsed once per load, not “hundreds of times/sec.”setSingletonImageLoaderFactory is itself a skippable @Composable (verified via javap on the Coil 3.4.0 compose-jvm bytecode: it uses Composer.startRestartGroup/changedInstance/shouldExecute and only calls the cheap SingletonImageLoader.setSafe(...) when the factory lambda instance actually changed). Not a meaningful hotspot.EditDiagramContent’s “no anchors detected” preview panel ran two Regex scans (Regex("<rect[^>]*>").findAll(svgContent).count() and svgContent.contains(Regex("id=\"k_...\""))) directly in the composable body, unmemoized. EditDiagramContent recomposes on every keystroke in the Name/Description/Source OutlinedTextFields (each onValueChange does meta = meta.copy(...), and the whole function reads meta directly), so those regex scans re-ran on every keystroke while editing a diagram whose SVG had no detected anchors — scaling with SVG length, not recomposition-cause-agnostic but real.countRectElements(svgContent) and containsKAnchorId(svgContent) in composeApp/.../project/diagram/DiagramScreen.kt.remember(svgContent) { ... } so they only re-evaluate when the loaded SVG content actually changes, not on unrelated recompositions.When a Kraken lead cites a function as “not defined in the file” as supporting evidence, treat that as a strong signal the review is stale/inaccurate — verify the claim by grepping the file directly before trusting the rest of the hypothesis. For Compose recomposition hotspot leads generally: check whether the flagged computation is already gated behind LaunchedEffect/remember with stable keys before assuming it runs on every recomposition — but don’t stop there; scan sibling code paths in the same file for the same pattern without the gating, since a plausible-sounding lead can be wrong about its cited location while still pointing at a real issue one composable over.