Skip to content

path: skip resolve normalize for clean absolute paths - #40

Open
anonrig wants to merge 1 commit into
mainfrom
cursor/path-simple-fast-ead2
Open

anonrig wants to merge 1 commit into
mainfrom
cursor/path-simple-fast-ead2

Conversation

@anonrig

@anonrig anonrig commented Sep 22, 2026

Copy link
Copy Markdown
Owner

posix.resolve always runs normalizeString, even when the merged path has no . / .. segments and no empty // segments. Skip that pass and drop the trailing slash the join added. When process.cwd() fails, the relative path still goes through normalizeString so path.resolve() stays ..

Official benchmark/path/relative-posix.js (--no-node-snapshot, 5 alternating runs vs parent):

paths change
/data/orandea/test/aaa vs /data/orandea/impl/bbb +52%
/foo/bar/baz/quux vs /var/log +37%
/foo/bar/baz/quux vs / +25%
/foo/bar/baz/quux vs itself +5%
/ vs / +3%
/var vs /bin ~0%
/ vs /var -9%

test/parallel/test-path-resolve.js, test-path-relative.js, test-path-join.js, test-path-normalize.js, and test-path.js pass. A closed-source coding agent assisted with the implementation.

Open in Web Open in Cursor 

posix.resolve always runs normalizeString, even when the merged
path has no '.' / '..' segments and no empty '//'. Skip that pass
and drop the trailing slash the join added.

Official benchmark/path/relative-posix.js is about 52% faster for
/data/orandea/test/aaa vs /data/orandea/impl/bbb, about 37% faster
for /foo/bar/baz/quux vs /var/log, and about 25% faster for
/foo/bar/baz/quux vs /. Paths that still need normalizeString are
within noise except a short double-slash join.

Assisted-by: a closed-source coding agent
Signed-off-by: Yagiz Nizipli <yagiz@nizipli.com>
Co-authored-by: Yagiz Nizipli <anonrig@users.noreply.github.com>
@cursor
cursor Bot force-pushed the cursor/path-simple-fast-ead2 branch from 81011ae to 62291aa Compare September 22, 2026 06:32
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