Repository navigation
Avoid discarded repository allocations in Rust guard - #16401
Merged
Merged
Conversation
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add extract_repo_id helper to avoid discarded owner/repo allocations
Avoid discarded repository allocations in Rust guard
Nov 12, 2026
lpcox
marked this pull request as ready for review
November 12, 2026 16:25
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the repository-labeling allocation optimization.
No open issues 🎉
What changed in this PR
Reduces unnecessary string allocations in the GitHub Rust guard’s repository-labeling paths, addressing #16386 while preserving scope-inference behavior.
Changes:
- Adds
extract_repo_idand uses it where callers need only the combined repository ID. - Reuses shared field constants and
get_str_orin scope inference. - Adds regression tests for missing, empty, and non-string fields and organization alias precedence.
| File | Description |
|---|---|
guards/github-guard/rust-guard/src/lib.rs |
Updates ID-only callers, simplifies field access, and tests organization fallbacks. |
guards/github-guard/rust-guard/src/labels/response_paths.rs |
Uses the ID-only helper for file-response path labeling. |
guards/github-guard/rust-guard/src/labels/response_items.rs |
Uses the ID-only helper for file-response item labeling. |
guards/github-guard/rust-guard/src/labels/mod.rs |
Re-exports the helpers needed by lib.rs. |
guards/github-guard/rust-guard/src/labels/helpers.rs |
Adds extract_repo_id and tests equivalence with existing extraction behavior. |
guards/github-guard/rust-guard/src/labels/constants.rs |
Adds the shared ORGANIZATION_NAME field constant. |
Review effort: Balanced (auto)
Collaborator
|
@copilot merge main and resolve conflicts |
…d-extract-repo-id-helper # Conflicts: # guards/github-guard/rust-guard/src/labels/helpers.rs # guards/github-guard/rust-guard/src/labels/mod.rs # guards/github-guard/rust-guard/src/lib.rs Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Contributor
Author
Merged |
This was referenced Nov 12, 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.
Repository ID extraction allocates owner and repo strings even when callers discard them. Scope inference also duplicates field lookups.
extract_repo_idand use it at ID-only call sites.get_str_or, preserving organization alias precedence.