perf: create link objects lazily#10951
Open
radoering wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- With
LinkCachenow holding factories instead ofLinkinstances, repeated iteration overlinks/links_for_versionwill rebuildLinkobjects each time; if these APIs are used frequently in hot paths, consider memoizing the constructedLinks per factory or documenting that callers should cache results if they rely on reuse. - In
HTMLPage._link_cache, the comment notes that links are built eagerly due to lack of a separate filename field; if this becomes a noticeable hotspot, you might consider a lightweight helper that extracts the filename from the URL without constructing a fullLink, to align with the lazy strategy introduced for the JSON source.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- With `LinkCache` now holding factories instead of `Link` instances, repeated iteration over `links`/`links_for_version` will rebuild `Link` objects each time; if these APIs are used frequently in hot paths, consider memoizing the constructed `Link`s per factory or documenting that callers should cache results if they rely on reuse.
- In `HTMLPage._link_cache`, the comment notes that links are built eagerly due to lack of a separate filename field; if this becomes a noticeable hotspot, you might consider a lightweight helper that extracts the filename from the URL without constructing a full `Link`, to align with the lazy strategy introduced for the JSON source.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Secrus
approved these changes
Jun 11, 2026
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.
Another small performance improvement, which makes locking about 10 % faster in some cases.