Skip to content

Commit ac2bce0

Browse files
evanlucasrvagg
authored andcommitted
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 <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
1 parent 9a593ab commit ac2bce0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

‎lib/path.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,9 @@ var posix ={};
408408

409409

410410
functionposixSplitPath(filename){
411-
returnsplitPathRe.exec(filename).slice(1);
411+
constout=splitPathRe.exec(filename);
412+
out.shift();
413+
returnout;
412414
}
413415

414416

0 commit comments

Comments
(0)