Resolve canvas vertices, ids, and style scope in one pass - #2124
Closed
kmcginnes wants to merge 1 commit into
Closed
Resolve canvas vertices, ids, and style scope in one pass#2124kmcginnes wants to merge 1 commit into
kmcginnes wants to merge 1 commit into
Conversation
Three passes over the canvas vertices became one. The visible-ids atom iterated every vertex, the style-scope atom iterated them again re-testing membership, and the render hook iterated a third time re-testing it once more — two passes existed only to re-discover a decision the first had already made. `canvasVerticesAtom` returns the drawn vertices, their ids, and the styles of the types they draw from a single loop, so the style scope and the drawn set cannot disagree: a drawn vertex's `primaryType` is in `stylesByType` by construction. That also collapses the reason a missing icon used to be silent. Style data was assembled from two inputs of different totality — scalar fields from a lookup that answers for any type, the icon from a partial scope list — so a scope miss was indistinguishable from a type that genuinely has no icon. The style data now derives entirely from the scoped style list, and a type absent from it is a loud throw rather than a node quietly drawn without its icon. The memoizing resolver layer is gone with it: five exported symbols, two factories and two cache closures replaced by one hook returning a plain per-type map. Edge style data is resolved on first sight of a type inside the existing filter loop, since the drawn edge types are only known while filtering.
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Three passes over the canvas vertices become one, and the resolver layer from #2119 collapses.
The visible-ids atom iterated every vertex; the style-scope atom iterated them again re-testing membership;
useRenderedVerticesiterated a third time re-testing it once more. Two passes existed only to re-discover a decision the first had already made.canvasVerticesAtomreturns the drawn vertices, their ids, and the styles of the types they draw from a single loop.That also removes the reason a missing icon used to be silent. Style data was assembled from two inputs of different totality — scalar fields from a lookup that answers for any type, the icon from a partial scope list — so
resolveStyleData(type)always succeeded and always looked plausible, and a scope miss was indistinguishable from a type that genuinely has no icon. Now a drawn vertex'sprimaryTypeis instylesByTypeby construction (same loop), the style data derives entirely from that scoped list, and a type absent from it throws rather than quietly drawing a node without its icon.The memoizing resolver layer goes with it: five exported symbols, two factories and two cache closures replaced by one hook returning a plain per-type map. The lazy memoization bought nothing because every caller knows its full key set up front — and the resolver function shape is what forced the total-lookup dependency, since a function must answer for any argument where a map need not.
The edge half is inlined rather than kept as a hook: the drawn edge types are only knowable while filtering, so producing them up front would need the extra pass this PR removes. Each consumer fills a per-render map on first sight of a type inside its existing loop — still one
Colorparse per type rather than per edge.Iteration order is unchanged; rendered vertices stay in canvas insertion order.
How to read
renderedEntities.ts—canvasVerticesAtom, then the two hooks.styleDataResolvers.ts— down to a single hook.useSchemaGraphData.ts— mirrors the same invariant assertion.