Skip to content

Commit

Permalink
path: improve posixSplitPath performance
Browse files Browse the repository at this point in the history
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
1 parent 1b78151 commit b50e89e
Showing 1 changed file with 3 additions and 1 deletion.
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

0 comments on commit b50e89e

Please sign in to comment.