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 <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
  • Loading branch information
evanlucas authored and rvagg committed Sep 30, 2015
1 parent 9a593ab commit ac2bce0
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 ac2bce0

Please sign in to comment.