Skip to content

perf(utils): skip path separator replace on POSIX - #1766

Merged
james-elicx merged 1 commit into
cloudflare:mainfrom
shulaoda:06-05-perf_utils_skip_path_separator_replace_on_posix
Jun 5, 2026
Merged

perf(utils): skip path separator replace on POSIX#1766
james-elicx merged 1 commit into
cloudflare:mainfrom
shulaoda:06-05-perf_utils_skip_path_separator_replace_on_posix

Conversation

@shulaoda

@shulaoda shulaoda commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Add an isWindows guard to normalizePathSeparators so it returns the input unchanged on POSIX instead of running a regex scan.

Motivation

normalizePathSeparators is called on hot paths — static file cache lookups, route discovery, and entry-module import generation. On Linux/macOS, backslashes never appear in filesystem paths, so the .replace(/\\/g, "/") always scans the full string and finds nothing. Gating it behind process.platform === "win32" makes it a no-op on POSIX while preserving the exact Windows behavior.

@pkg-pr-new

pkg-pr-new Bot commented Jun 5, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@vinext/cloudflare@1766
npm i https://pkg.pr.new/vinext@1766

commit: 0117497

@james-elicx
james-elicx merged commit ab4f2dc into cloudflare:main Jun 5, 2026
29 checks passed
@github-actions github-actions Bot mentioned this pull request Jun 5, 2026
@shulaoda
shulaoda deleted the 06-05-perf_utils_skip_path_separator_replace_on_posix branch June 5, 2026 15:40
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.

2 participants