Skip to content

perf: remove a useless load_as_directory call#487

Merged
Boshen merged 1 commit intomainfrom
05-01-perf_remove_a_useless_load_as_directory_call
May 1, 2025
Merged

perf: remove a useless load_as_directory call#487
Boshen merged 1 commit intomainfrom
05-01-perf_remove_a_useless_load_as_directory_call

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented May 1, 2025

Summary by CodeRabbit

  • Refactor
    • Improved efficiency by removing redundant directory loading attempts during module resolution.

@coderabbitai
Copy link

coderabbitai bot commented May 1, 2025

Walkthrough

The update modifies the load_node_modules method in src/lib.rs by removing a redundant invocation of the load_as_directory function. Previously, the method attempted to load the same directory twice under certain conditions. With this change, the method now attempts to load each directory only once per iteration, streamlining the process while maintaining the existing control flow and error handling. No changes were made to the declarations of exported or public entities.

Changes

File(s) Change Summary
src/lib.rs Removed a redundant call to load_as_directory within the load_node_modules method.

Poem

In the warren of code, a path was retraced,
Twice through the tunnel, but one was erased.
Now with one hop, the journey is done,
No more doubling back—just a single run!
The rabbit rejoices, the way is now clear,
For streamlined adventures throughout the year. 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f64911c and de4d73d.

📒 Files selected for processing (1)
  • src/lib.rs (0 hunks)
💤 Files with no reviewable changes (1)
  • src/lib.rs
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Test (macos-14)
  • GitHub Check: Test (windows-latest)
  • GitHub Check: Benchmark
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Member Author

Boshen commented May 1, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codecov
Copy link

codecov bot commented May 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.83%. Comparing base (f64911c) to head (de4d73d).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #487      +/-   ##
==========================================
+ Coverage   93.80%   93.83%   +0.02%     
==========================================
  Files          13       13              
  Lines        2791     2788       -3     
==========================================
- Hits         2618     2616       -2     
+ Misses        173      172       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq
Copy link

codspeed-hq bot commented May 1, 2025

CodSpeed Performance Report

Merging #487 will not alter performance

Comparing 05-01-perf_remove_a_useless_load_as_directory_call (de4d73d) with main (f64911c)

Summary

✅ 3 untouched benchmarks

@Boshen Boshen merged commit 00bf216 into main May 1, 2025
20 checks passed
@Boshen Boshen deleted the 05-01-perf_remove_a_useless_load_as_directory_call branch May 1, 2025 02:46
@oxc-bot oxc-bot mentioned this pull request May 1, 2025
Boshen pushed a commit that referenced this pull request May 1, 2025
## 🤖 New release

* `oxc_resolver`: 7.0.1 -> 8.0.0 (⚠ API breaking changes)

### ⚠ `oxc_resolver` breaking changes

```text
--- failure inherent_method_missing: pub method removed or renamed ---

Description:
A publicly-visible method or associated fn is no longer available under its prior name. It may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/inherent_method_missing.ron

Failed in:
  ResolveOptions::with_module, previously in file /tmp/.tmpCfZ3uE/oxc_resolver/src/options.rs:342

--- failure struct_pub_field_missing: pub struct's pub field removed or renamed ---

Description:
A publicly-visible struct has at least one public field that is no longer available under its prior name. It may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/struct_pub_field_missing.ron

Failed in:
  field description_files of struct ResolveOptions, previously in file /tmp/.tmpCfZ3uE/oxc_resolver/src/options.rs:47
  field modules of struct ResolveOptions, previously in file /tmp/.tmpCfZ3uE/oxc_resolver/src/options.rs:119

--- failure trait_method_added: pub trait method added ---

Description:
A non-sealed public trait added a new method without a default implementation, which breaks downstream implementations of the trait
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-item-no-default
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/trait_method_added.ron

Failed in:
  trait method oxc_resolver::CachedPath::is_node_modules in file /tmp/.tmpoUaDz8/oxc-resolver/src/cache.rs:65
  trait method oxc_resolver::CachedPath::inside_node_modules in file /tmp/.tmpoUaDz8/oxc-resolver/src/cache.rs:67

--- failure trait_method_missing: pub trait method removed or renamed ---

Description:
A trait method is no longer callable, and may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#major-any-change-to-trait-item-signatures
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/trait_method_missing.ron

Failed in:
  method node_modules of trait CachedPath, previously in file /tmp/.tmpCfZ3uE/oxc_resolver/src/cache.rs:65
  method module_directory of trait CachedPath, previously in file /tmp/.tmpCfZ3uE/oxc_resolver/src/cache.rs:67
  method cached_node_modules of trait CachedPath, previously in file /tmp/.tmpCfZ3uE/oxc_resolver/src/cache.rs:74
```

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

##
[8.0.0](oxc_resolver-v7.0.1...oxc_resolver-v8.0.0)
- 2025-05-01

### <!-- 1 -->Bug Fixes

- fix incorrect return of package.json when a workspace module has
`node_modules`
([#482](#482))

### <!-- 2 -->Performance

- cache whether a path is `node_modules` or inside `node_modules`
([#490](#490))
- remove a useless `load_as_directory` call
([#487](#487))

### <!-- 4 -->Refactor

- [**breaking**] remove `description_files` option
([#488](#488))
- [**breaking**] remove `modules` options
([#484](#484))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Documentation**
- Added a new changelog entry for version 8.0.0, highlighting a bug fix,
performance improvements, and breaking changes.
- **Chores**
  - Updated the package version to 8.0.0 in project files.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

1 participant