Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Böhm <felixboehm55@googlemail.com>2012-05-20 23:26:29 +0400
committerBen Noordhuis <info@bnoordhuis.nl>2012-08-10 14:55:49 +0400
commitd15bfc04cde2bbfb2ce534639255dfcdab3cfcb3 (patch)
tree76e5bbb05d2d900107d7e17d5c8d537fcb1c41dc /lib/path.js
parent9693d3334c9906840132764c91b4ec399a7a5cfd (diff)
path: small speed improvements
Diffstat (limited to 'lib/path.js')
-rw-r--r--lib/path.js18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/path.js b/lib/path.js
index 438b05d8ef6..88c2df8cd71 100644
--- a/lib/path.js
+++ b/lib/path.js
@@ -33,7 +33,7 @@ function normalizeArray(parts, allowAboveRoot) {
var up = 0;
for (var i = parts.length - 1; i >= 0; i--) {
var last = parts[i];
- if (last == '.') {
+ if (last === '.') {
parts.splice(i, 1);
} else if (last === '..') {
parts.splice(i, 1);
@@ -101,7 +101,7 @@ if (isWindows) {
path = process.env['=' + resolvedDevice];
// Verify that a drive-local cwd was found and that it actually points
// to our drive. If not, default to the drive's root.
- if (!path || path.slice(0, 3).toLowerCase() !==
+ if (!path || path.substr(0, 3).toLowerCase() !==
resolvedDevice.toLowerCase() + '\\') {
path = resolvedDevice + '\\';
}
@@ -191,14 +191,14 @@ if (isWindows) {
return p && typeof p === 'string';
}
- var paths = Array.prototype.slice.call(arguments, 0).filter(f);
+ var paths = Array.prototype.filter.call(arguments, f);
var joined = paths.join('\\');
// Make sure that the joined path doesn't start with two slashes
// - it will be mistaken for an unc path by normalize() -
// unless the paths[0] also starts with two slashes
if (/^[\\\/]{2}/.test(joined) && !/^[\\\/]{2}/.test(paths[0])) {
- joined = joined.slice(1);
+ joined = joined.substr(1);
}
return exports.normalize(joined);
@@ -307,7 +307,7 @@ if (isWindows) {
// posix version
exports.normalize = function(path) {
var isAbsolute = path.charAt(0) === '/',
- trailingSlash = path.slice(-1) === '/';
+ trailingSlash = path.substr(-1) === '/';
// Normalize the path
path = normalizeArray(path.split('/').filter(function(p) {
@@ -393,7 +393,7 @@ exports.dirname = function(path) {
if (dir) {
// It has a dirname, strip trailing slash
- dir = dir.substring(0, dir.length - 1);
+ dir = dir.substr(0, dir.length - 1);
}
return root + dir;
@@ -434,11 +434,11 @@ if (isWindows) {
var resolvedPath = exports.resolve(path);
- if (resolvedPath.match(/^[a-zA-Z]\:\\/)) {
+ if (/^[a-zA-Z]\:\\/.test(resolvedPath)) {
// path is local filesystem path, which needs to be converted
// to long UNC path.
return '\\\\?\\' + resolvedPath;
- } else if (resolvedPath.match(/^\\\\[^?.]/)) {
+ } else if (/^\\\\[^?.]/.test(resolvedPath)) {
// path is network UNC path, which needs to be converted
// to long UNC path.
return '\\\\?\\UNC\\' + resolvedPath.substring(2);
@@ -450,4 +450,4 @@ if (isWindows) {
exports._makeLong = function(path) {
return path;
};
-}
+} \ No newline at end of file