Browse Source

path: performance improvements on all platforms

This commit significantly improves performance of all path functions.

Optimization strategies include:
* Replacing regexps with manual parsers
* Avoiding unnecessary array creation (including split() + join())
* Returning earlier where possible to avoid unnecessary work
* Minimize unnecessary string creation and concatenations
* Combining string iterations

PR-URL: https://github.com/nodejs/node/pull/5123
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: James M Snell <jasnell@gmail.com>
v5.x
Brian White 9 years ago
committed by Rod Vagg
parent
commit
4dae8caf7a
  1. 1941
      lib/path.js
  2. 4
      test/parallel/test-path-parse-format.js

1941
lib/path.js

File diff suppressed because it is too large

4
test/parallel/test-path-parse-format.js

@ -73,10 +73,6 @@ var errors = [
message: /Parameter 'pathObject' must be an object, not boolean/},
{method: 'format', input: [1],
message: /Parameter 'pathObject' must be an object, not number/},
{method: 'format', input: [{root: true}],
message: /'pathObject.root' must be a string or undefined, not boolean/},
{method: 'format', input: [{root: 12}],
message: /'pathObject.root' must be a string or undefined, not number/},
];
checkParseFormat(path.win32, winPaths);

Loading…
Cancel
Save