You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PPTX: index relationships by id on import and by target on export - #1739
Two relationship lookups in crates/pptx/src/opc.rs scanned a list that the file controls:
Reading:Rels::get(id) searched the part's whole relationship list for each id it resolved. A slide list resolves an id per slide, so many references against a long .rels part cost references × relationships.
Writing:RelsOut::add checked for an identical relationship by scanning every relationship already added to the part. Export adds one per hyperlink, picture and so on, so many distinct hyperlink targets made export quadratic.
What changed
Rels keeps an id → index map, filled while the .rels part is parsed. get (and so target) is a map lookup. A repeated id still resolves to its first relationship, as before.
RelsOut keeps a (type, target, external) → id map. add reuses an id through it. add_new also records its relationship, the first for a target, so a later add still reuses it as before.
Added a test: 50,000 relationships plus a repeated id (the first wins), then 50,000 distinct hyperlinks added, an identical one reused, and the add_new/add interplay.
Blast radius
Only deckcraft-pptx relationship bookkeeping. Ids, order and output are unchanged. RelsOut.items stays public, and the code that fills it directly (kept chart parts) does not call add afterwards.
Also checked: content types are already parsed once per package (ct_cache), and kept chart relationships are already built once per payload (seen_payloads). Neither needed a change.
cargo test -p deckcraft-pptx (unit, chart_data_labels, the it suite)
Checks not run
The full cargo xtask ci
Summary by CodeRabbit
Performance
Improved relationship lookups and reuse when working with presentations containing many linked resources. This may help large presentations process more efficiently.
No actionable comments were generated in the recent review.
Walkthrough
Relationship lookup and reuse now use indexes in place of linear scans. Duplicate relationship IDs resolve to the first item. The added test checks lookup and reuse behavior across 50,000 relationships.
Rels looks up IDs through an index that retains the first item for duplicate IDs. RelsOut::add reuses IDs through an index keyed by relationship type, target, and external status. add_new continues to append distinct relationships. A test checks lookup, reuse, and distinction between internal and external relationships across 50,000 relationships.
No actionable issue remains from this review; the change is mergeable after normal checks.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the two main changes: relationships are indexed by ID on import and by target on export. The raw summary confirms this. Import indexes the relationship ID map, and export indexes by ty…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the two main changes: relationships are indexed by ID on import and by target on export. The raw summary confirms this. Import indexes the relationship ID map, and export indexes by type, target, and external status. The title is specific and matches the changeset. It names the export key as target, while the code also keys on type and external status, so the title is slightly narrower than the full key, but it is still a fair summary.
Full details: Docstring Coverage
Explanation
Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 1 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Finishing Touches
Generate docstrings
Commit to this branch
Create a new PR
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between 0c00f22 and cab5e55.
Files selected for processing: 1
crates/pptx/src/opc.rs
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.
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
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.
What was wrong
Two relationship lookups in
crates/pptx/src/opc.rsscanned a list that the file controls:Rels::get(id)searched the part's whole relationship list for each id it resolved. A slide list resolves an id per slide, so many references against a long.relspart cost references × relationships.RelsOut::addchecked for an identical relationship by scanning every relationship already added to the part. Export adds one per hyperlink, picture and so on, so many distinct hyperlink targets made export quadratic.What changed
Relskeeps an id → index map, filled while the.relspart is parsed.get(and sotarget) is a map lookup. A repeated id still resolves to its first relationship, as before.RelsOutkeeps a (type, target, external) → id map.addreuses an id through it.add_newalso records its relationship, the first for a target, so a lateraddstill reuses it as before.add_new/addinterplay.Blast radius
Only
deckcraft-pptxrelationship bookkeeping. Ids, order and output are unchanged.RelsOut.itemsstays public, and the code that fills it directly (kept chart parts) does not calladdafterwards.Also checked: content types are already parsed once per package (
ct_cache), and kept chart relationships are already built once per payload (seen_payloads). Neither needed a change.Checks run
cargo fmt -p deckcraft-pptx --checkcargo clippy -p deckcraft-pptx --all-targets -- -D warningscargo test -p deckcraft-pptx(unit,chart_data_labels, theitsuite)Checks not run
cargo xtask ciSummary by CodeRabbit