Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
path: improve posixSplitPath performance
Instead of slicing the first element off of the matches, shift and then
return. This improves performance of the following path functions:

- basename: 18-20%
- extname: 60-70%
- dirname: 18-20%
- parse: 20-25%

PR-URL: #3034
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
  • Loading branch information
evanlucas committed Sep 25, 2015
commit b50e89e01f36c4abd048a194991f2ce88725773a
4 changes: 3 additions & 1 deletion lib/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,9 @@ var posix = {};


function posixSplitPath(filename) {
return splitPathRe.exec(filename).slice(1);
const out = splitPathRe.exec(filename);
out.shift();
return out;
}


Expand Down