Commit 5f4bde9
committed
perf: avoid redundant PathBuf allocations in resolve paths (#8435)
- Skip `cwd.join(importer)` when importer is already an absolute path,
passing `&Path` directly to `resolve_file()` instead of allocating a
new PathBuf (~50K avoided allocations per 10K module build)
- Apply the same optimization in rolldown_plugin_vite_resolve (2 sites)
- Point oxc_resolver to local path for coordinated optimization
Combined with the oxc-resolver changes oxc-project/oxc-resolver#1027, this eliminates ~174K
`to_path_buf` allocations (21.3 MB) down to effectively zero,
yielding ~9% faster JS API median on a 10K module benchmark.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Small, localized change to how importer paths are passed into the resolver; primary risk is subtle behavior differences if callers pass unusual absolute/relative importer strings.
>
> **Overview**
> Reduces resolve-time allocations by detecting when an `importer` is already an absolute path and calling `resolve_file(importer, ...)` directly instead of `cwd.join(importer)`/`root.join(importer)`.
>
> Applies this optimization in `rolldown_resolver::Resolver::resolve` and in two resolution paths in `rolldown_plugin_vite_resolve::Resolver::resolve_raw` (including the `try_prefix` fallback).
>
> <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 51016de. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent b10740d commit 5f4bde9
File tree
2 files changed
+18
-3
lines changed- crates
- rolldown_plugin_vite_resolve/src
- rolldown_resolver/src
2 files changed
+18
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
284 | | - | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
285 | 290 | | |
286 | 291 | | |
287 | 292 | | |
| |||
321 | 326 | | |
322 | 327 | | |
323 | 328 | | |
324 | | - | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
325 | 335 | | |
326 | 336 | | |
327 | 337 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
155 | 160 | | |
156 | 161 | | |
157 | 162 | | |
| |||
0 commit comments