Comparing version 6.1.10 to 6.1.11
@@ -10,3 +10,3 @@ // A path exclusive reservation system | ||
const assert = require('assert') | ||
const normPath = require('./normalize-windows-path.js') | ||
const normalize = require('./normalize-unicode.js') | ||
const stripSlashes = require('./strip-trailing-slashes.js') | ||
@@ -32,3 +32,3 @@ const { join } = require('path') | ||
if (set.length) | ||
path = normPath(join(set[set.length - 1], path)) | ||
path = join(set[set.length - 1], path) | ||
set.push(path || '/') | ||
@@ -121,5 +121,4 @@ return set | ||
paths = isWindows ? ['win32 parallelization disabled'] : paths.map(p => { | ||
return stripSlashes(normPath(join(p))) | ||
.normalize('NFKD') | ||
.toLowerCase() | ||
// don't need normPath, because we skip this entirely for windows | ||
return normalize(stripSlashes(join(p))).toLowerCase() | ||
}) | ||
@@ -126,0 +125,0 @@ |
@@ -1,24 +0,13 @@ | ||
// this is the only approach that was significantly faster than using | ||
// str.replace(/\/+$/, '') for strings ending with a lot of / chars and | ||
// containing multiple / chars. | ||
const batchStrings = [ | ||
'/'.repeat(1024), | ||
'/'.repeat(512), | ||
'/'.repeat(256), | ||
'/'.repeat(128), | ||
'/'.repeat(64), | ||
'/'.repeat(32), | ||
'/'.repeat(16), | ||
'/'.repeat(8), | ||
'/'.repeat(4), | ||
'/'.repeat(2), | ||
'/', | ||
] | ||
// warning: extremely hot code path. | ||
// This has been meticulously optimized for use | ||
// within npm install on large package trees. | ||
// Do not edit without careful benchmarking. | ||
module.exports = str => { | ||
for (const s of batchStrings) { | ||
while (str.length >= s.length && str.slice(-1 * s.length) === s) | ||
str = str.slice(0, -1 * s.length) | ||
let i = str.length - 1 | ||
let slashesStart = -1 | ||
while (i > -1 && str.charAt(i) === '/') { | ||
slashesStart = i | ||
i-- | ||
} | ||
return str | ||
return slashesStart === -1 ? str : str.slice(0, slashesStart) | ||
} |
@@ -20,2 +20,3 @@ 'use strict' | ||
const stripSlash = require('./strip-trailing-slashes.js') | ||
const normalize = require('./normalize-unicode.js') | ||
@@ -105,4 +106,3 @@ const ONENTRY = Symbol('onEntry') | ||
// to reason about, and collisions are hazards rather than just failures. | ||
const cacheKeyNormalize = path => stripSlash(normPath(path)) | ||
.normalize('NFKD') | ||
const cacheKeyNormalize = path => normalize(stripSlash(normPath(path))) | ||
.toLowerCase() | ||
@@ -109,0 +109,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"description": "tar for node", | ||
"version": "6.1.10", | ||
"version": "6.1.11", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
160662
29