Commit ca37e8f
committed
url: skip resolve for already-absolute POSIX paths
pathToFileURL always called path.resolve, even when the input was
already an absolute POSIX path with no '.' / '..' or empty
segments. Reuse that path and drop a trailing slash the same way
posix.resolve does, so the later restore does not append a second
slash when path.sep is '\' (Windows host, windows: false).
Official benchmark/url/whatwg-url-to-and-from-path.js
pathToFileURL is about 27% faster for /dev/null and about 45-48%
faster when the path has a query or hash. fileURLToPath is
unchanged.
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>1 parent dd5dfb5 commit ca37e8f
1 file changed
Lines changed: 24 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1673 | 1673 | | |
1674 | 1674 | | |
1675 | 1675 | | |
1676 | | - | |
1677 | | - | |
1678 | | - | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
| 1692 | + | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
| 1698 | + | |
| 1699 | + | |
1679 | 1700 | | |
1680 | 1701 | | |
1681 | 1702 | | |
| |||
0 commit comments