Skip to content

perf: optimize file extension discovery in technology detection#418

Merged
yacosta738 merged 1 commit into
mainfrom
perf-optimize-extension-discovery-10111704374037346123
May 14, 2026
Merged

perf: optimize file extension discovery in technology detection#418
yacosta738 merged 1 commit into
mainfrom
perf-optimize-extension-discovery-10111704374037346123

Conversation

@yacosta738
Copy link
Copy Markdown
Contributor

💡 What: Optimized RepoMetadata::collect in src/skills/detect.rs to avoid redundant string allocations and map insertions for file extensions.
🎯 Why: The original code performed string formatting and map lookups for every file encountered during the directory walk, even for common extensions already processed.
📊 Impact: Reduces heap allocations from O(N) to O(M) where N is the number of files and M is the number of unique extensions. This significantly improves performance in large projects with thousands of files.
🔬 Measurement: Verified with cargo test skills::detect and confirmed logic avoids redundant work.


PR created automatically by Jules for task 10111704374037346123 started by @yacosta738

Avoid redundant string allocations and map insertions by checking if an extension
has already been recorded before performing format! and to_string() operations.
In projects with many files, this reduces O(N) allocations to O(M) where M is
the number of unique extensions.
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

RepoMetadata::collect optimizes file extension recording during directory traversal by checking whether an extension already exists in the map before performing formatting and insertion operations. When present, formatting and insertion work are skipped entirely; when absent, both the dotted and non-dotted extension forms are inserted in a single conditional block.

Changes

Extension Collection Performance

Layer / File(s) Summary
Extension map efficiency check
src/skills/detect.rs
RepoMetadata::collect avoids constructing dot_ext and calling or_insert when the extension key is already present; both extension forms are inserted together in one conditional block when needed.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A rabbit hops through files with glee,
Finding extensions it can quickly see—
No extra work when already known,
One check replaces duplicates shown!
Efficiency blooms in the code we sow. 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description is directly related to the changeset, explaining the optimization of RepoMetadata::collect to avoid redundant string allocations and map insertions for file extensions.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title 'perf: optimize file extension discovery in technology detection' directly and clearly summarizes the main change—optimizing how file extensions are discovered in the technology detection module.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf-optimize-extension-discovery-10111704374037346123

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sentry
Copy link
Copy Markdown

sentry Bot commented May 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sonarqubecloud
Copy link
Copy Markdown

@yacosta738 yacosta738 changed the title ⚡ Bolt: optimize file extension discovery in technology detection perf: optimize file extension discovery in technology detection May 14, 2026
@yacosta738 yacosta738 marked this pull request as ready for review May 14, 2026 19:18
@yacosta738 yacosta738 merged commit da781df into main May 14, 2026
27 of 28 checks passed
@yacosta738 yacosta738 deleted the perf-optimize-extension-discovery-10111704374037346123 branch May 14, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant