Skip to content

perf(deps): move regex compilation to lazy_static#2689

Open
guyoron1 wants to merge 1 commit into
rtk-ai:developfrom
guyoron1:perf/deps-lazy-regex
Open

perf(deps): move regex compilation to lazy_static#2689
guyoron1 wants to merge 1 commit into
rtk-ai:developfrom
guyoron1:perf/deps-lazy-regex

Conversation

@guyoron1

Copy link
Copy Markdown
Contributor

Summary

Three Regex::new() calls in deps.rs use static patterns but were compiled
inside function bodies (summarize_cargo_str, summarize_requirements_str),
causing recompilation on every invocation.

Moves all three to a lazy_static! block at module scope so they compile once
at first use, following the established RTK convention.

Changes

  • src/cmds/system/deps.rs: Moved dep_re, section_re, and requirements
    dep_re to lazy_static! block as CARGO_DEP_RE, CARGO_SECTION_RE, and
    REQUIREMENTS_DEP_RE

Test plan

  • cargo fmt --all — no formatting issues
  • cargo clippy --all-targets — no warnings
  • cargo test --all — all tests pass
  • Behavior unchanged (same regex patterns, same matching logic)

Fixes #2688

Three Regex::new() calls in deps.rs used static patterns but were
compiled inside function bodies, causing recompilation on every
invocation of summarize_cargo_str and summarize_requirements_str.

Move all three to a lazy_static! block at module scope so they compile
once at first use.

Fixes rtk-ai#2688
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(deps): regex recompiled on every call in summarize_cargo_str and summarize_requirements_str

1 participant