Browse Source

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: https://github.com/nodejs/node/pull/3034
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
v5.x
Evan Lucas 9 years ago
parent
commit
b50e89e01f
  1. 4
      lib/path.js

4
lib/path.js

@ -408,7 +408,9 @@ var posix = {};
function posixSplitPath(filename) {
return splitPathRe.exec(filename).slice(1);
const out = splitPathRe.exec(filename);
out.shift();
return out;
}

Loading…
Cancel
Save