Skip to content

fix(engine): replace str::replace with cow_replace in module loader#5141

Merged
jedel1043 merged 2 commits intoboa-dev:mainfrom
iammdzaidalam:fix-clippy-cow-replace
Mar 18, 2026
Merged

fix(engine): replace str::replace with cow_replace in module loader#5141
jedel1043 merged 2 commits intoboa-dev:mainfrom
iammdzaidalam:fix-clippy-cow-replace

Conversation

@iammdzaidalam
Copy link
Copy Markdown
Contributor

Closes #5140

Replaces str::replace with cow_utils::CowUtils::cow_replace in the module loader to satisfy clippy::disallowed_methods and avoid unnecessary allocation.

Follows the pattern introduced in #4123.

@iammdzaidalam iammdzaidalam requested a review from a team as a code owner March 18, 2026 22:31
@github-actions github-actions Bot added C-Builtins PRs and Issues related to builtins/intrinsics Waiting On Review Waiting on reviews from the maintainers labels Mar 18, 2026
@github-actions github-actions Bot added this to the v1.0.0 milestone Mar 18, 2026
Comment thread core/engine/src/module/loader/mod.rs Outdated
// On Windows, also replace `/` with `\`. JavaScript imports use `/` as path separator.
#[cfg(target_family = "windows")]
let specifier = specifier.replace('/', "\\");
let specifier = specifier.cow_replace('/', "\\").into_owned();
Copy link
Copy Markdown
Member

@jedel1043 jedel1043 Mar 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to use the trait directly instead of importing

cow_utils::CowUtils::cow_replace(specifier, '/', "\\")

Also, using cow_replace then into_owned immediately after is... an interesting decision, because it's basically nullifying the use of cow_replace.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, resolved 👍

Copy link
Copy Markdown
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jedel1043 jedel1043 added the A-Technical Debt Changes related to technical debt label Mar 18, 2026
@jedel1043 jedel1043 enabled auto-merge March 18, 2026 22:45
@github-actions
Copy link
Copy Markdown

Test262 conformance changes

Test result main count PR count difference
Total 52,963 52,963 0
Passed 50,073 50,073 0
Ignored 2,072 2,072 0
Failed 818 818 0
Panics 0 0 0
Conformance 94.54% 94.54% 0.00%

Tested main commit: 50f0103d9188d33862efbc38397a81e497973632
Tested PR commit: 7c5509a9d66cd0c12ebf0b44cea4e2b6bea46408
Compare commits: 50f0103...7c5509a

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.35%. Comparing base (6ddc2b4) to head (7c5509a).
⚠️ Report is 889 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5141       +/-   ##
===========================================
+ Coverage   47.24%   59.35%   +12.11%     
===========================================
  Files         476      580      +104     
  Lines       46892    63181    +16289     
===========================================
+ Hits        22154    37502    +15348     
- Misses      24738    25679      +941     

☔ 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.

@jedel1043 jedel1043 added this pull request to the merge queue Mar 18, 2026
Merged via the queue into boa-dev:main with commit c2f7e99 Mar 18, 2026
22 checks passed
@github-actions github-actions Bot removed the Waiting On Review Waiting on reviews from the maintainers label Mar 18, 2026
@jedel1043 jedel1043 removed the C-Builtins PRs and Issues related to builtins/intrinsics label Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Technical Debt Changes related to technical debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remaining str::replace usage flagged by clippy::disallowed_methods in module loader

2 participants