@diffci.com/diffci 0.3.65 → 0.3.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-client/src/client/isolated-worktree.d.ts +16 -0
- package/dist-client/src/client/isolated-worktree.js +67 -1
- package/node_modules/@babel/helper-string-parser/lib/index.js +15 -6
- package/node_modules/@babel/helper-string-parser/lib/index.js.map +1 -1
- package/node_modules/@babel/helper-string-parser/package.json +1 -1
- package/node_modules/@babel/parser/lib/index.js +326 -93
- package/node_modules/@babel/parser/lib/index.js.map +1 -1
- package/node_modules/@babel/parser/package.json +3 -3
- package/node_modules/@babel/parser/typings/babel-parser.d.ts +23 -25
- package/node_modules/@babel/types/lib/ast-types/generated/index.js.map +1 -1
- package/node_modules/@babel/types/lib/clone/cloneNode.js.map +1 -1
- package/node_modules/@babel/types/lib/definitions/core.js +4 -0
- package/node_modules/@babel/types/lib/definitions/core.js.map +1 -1
- package/node_modules/@babel/types/lib/index-legacy.d.ts +1 -0
- package/node_modules/@babel/types/lib/index.d.ts +5 -5
- package/node_modules/@babel/types/lib/index.js.flow +1 -0
- package/node_modules/@babel/types/lib/validators/is.js.map +1 -1
- package/node_modules/@babel/types/lib/validators/isSpecifierDefault.js +5 -1
- package/node_modules/@babel/types/lib/validators/isSpecifierDefault.js.map +1 -1
- package/node_modules/@babel/types/package.json +4 -4
- package/node_modules/@diffci.com/core/README.md +1 -1
- package/node_modules/@diffci.com/core/dist/git/git-diff.js +7 -4
- package/node_modules/@diffci.com/core/dist/git/git-diff.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/git/types.d.ts +4 -0
- package/node_modules/@diffci.com/core/dist/repo/adapters/maven.js +16 -10
- package/node_modules/@diffci.com/core/dist/repo/adapters/maven.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/graph.js +8 -3
- package/node_modules/@diffci.com/core/dist/repo/graph.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/impact.js +4 -1
- package/node_modules/@diffci.com/core/dist/repo/impact.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/npm-lockfile.d.ts +11 -0
- package/node_modules/@diffci.com/core/dist/repo/npm-lockfile.js +45 -0
- package/node_modules/@diffci.com/core/dist/repo/npm-lockfile.js.map +1 -1
- package/node_modules/@diffci.com/core/package.json +1 -1
- package/node_modules/@diffci.com/core/src/git/git-diff.ts +6 -4
- package/node_modules/@diffci.com/core/src/git/types.ts +4 -0
- package/node_modules/@diffci.com/core/src/repo/adapters/maven.ts +16 -9
- package/node_modules/@diffci.com/core/src/repo/graph.ts +8 -3
- package/node_modules/@diffci.com/core/src/repo/impact.ts +4 -1
- package/node_modules/@diffci.com/core/src/repo/npm-lockfile.ts +39 -0
- package/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +115 -71
- package/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map +2 -2
- package/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js +115 -71
- package/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js.map +2 -2
- package/node_modules/@jridgewell/sourcemap-codec/package.json +2 -1
- package/node_modules/@jridgewell/sourcemap-codec/src/range-mappings.ts +47 -0
- package/node_modules/@jridgewell/sourcemap-codec/src/scopes.ts +66 -46
- package/node_modules/@jridgewell/sourcemap-codec/src/sourcemap-codec.ts +27 -11
- package/node_modules/@jridgewell/sourcemap-codec/src/vlq.ts +13 -17
- package/node_modules/@jridgewell/sourcemap-codec/types/range-mappings.d.cts +5 -0
- package/node_modules/@jridgewell/sourcemap-codec/types/range-mappings.d.cts.map +1 -0
- package/node_modules/@jridgewell/sourcemap-codec/types/range-mappings.d.mts +5 -0
- package/node_modules/@jridgewell/sourcemap-codec/types/range-mappings.d.mts.map +1 -0
- package/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.cts.map +1 -1
- package/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.mts.map +1 -1
- package/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.cts +2 -0
- package/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.cts.map +1 -1
- package/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.mts +2 -0
- package/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.mts.map +1 -1
- package/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.cts +4 -2
- package/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.cts.map +1 -1
- package/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.mts +4 -2
- package/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.mts.map +1 -1
- package/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js +6 -2
- package/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js +6 -2
- package/node_modules/@vue/compiler-core/dist/compiler-core.esm-bundler.js +6 -2
- package/node_modules/@vue/compiler-core/package.json +4 -4
- package/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.js +8 -8
- package/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +8 -8
- package/node_modules/@vue/compiler-dom/dist/compiler-dom.esm-browser.js +14 -14
- package/node_modules/@vue/compiler-dom/dist/compiler-dom.esm-browser.prod.js +2 -2
- package/node_modules/@vue/compiler-dom/dist/compiler-dom.esm-bundler.js +1 -1
- package/node_modules/@vue/compiler-dom/dist/compiler-dom.global.js +14 -14
- package/node_modules/@vue/compiler-dom/dist/compiler-dom.global.prod.js +2 -2
- package/node_modules/@vue/compiler-dom/package.json +3 -3
- package/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +1847 -1370
- package/node_modules/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +6462 -6187
- package/node_modules/@vue/compiler-sfc/package.json +11 -11
- package/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +32 -9
- package/node_modules/@vue/compiler-ssr/package.json +3 -3
- package/node_modules/@vue/shared/dist/shared.cjs.js +11 -15
- package/node_modules/@vue/shared/dist/shared.cjs.prod.js +11 -15
- package/node_modules/@vue/shared/dist/shared.esm-bundler.js +11 -15
- package/node_modules/@vue/shared/package.json +1 -1
- package/node_modules/postcss/lib/css-syntax-error.js +6 -4
- package/node_modules/postcss/lib/declaration.d.ts +2 -2
- package/node_modules/postcss/lib/map-generator.js +12 -2
- package/node_modules/postcss/lib/processor.js +1 -1
- package/node_modules/postcss/lib/tokenize.js +6 -13
- package/node_modules/postcss/package.json +1 -1
- package/node_modules/source-map-js/README.md +192 -176
- package/node_modules/source-map-js/lib/array-set.js +5 -3
- package/node_modules/source-map-js/lib/base64-vlq.js +5 -9
- package/node_modules/source-map-js/lib/base64.js +13 -12
- package/node_modules/source-map-js/lib/binary-search.js +10 -6
- package/node_modules/source-map-js/lib/mapping-list.js +12 -7
- package/node_modules/source-map-js/lib/quick-sort.js +93 -23
- package/node_modules/source-map-js/lib/source-map-consumer.js +272 -194
- package/node_modules/source-map-js/lib/source-map-generator.js +146 -106
- package/node_modules/source-map-js/lib/source-node.js +144 -118
- package/node_modules/source-map-js/lib/util.js +56 -37
- package/node_modules/source-map-js/package.json +14 -7
- package/node_modules/source-map-js/source-map.d.ts +177 -63
- package/node_modules/source-map-js/source-map.js +4 -2
- package/package.json +3 -3
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
var util = require('./util');
|
|
9
9
|
var has = Object.prototype.hasOwnProperty;
|
|
10
|
-
var hasNativeMap = typeof Map !==
|
|
10
|
+
var hasNativeMap = typeof Map !== 'undefined';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* A data structure which is a combination of an array and a set. Adding a new
|
|
@@ -38,7 +38,9 @@ ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
|
|
|
38
38
|
* @returns Number
|
|
39
39
|
*/
|
|
40
40
|
ArraySet.prototype.size = function ArraySet_size() {
|
|
41
|
-
return hasNativeMap
|
|
41
|
+
return hasNativeMap
|
|
42
|
+
? this._set.size
|
|
43
|
+
: Object.getOwnPropertyNames(this._set).length;
|
|
42
44
|
};
|
|
43
45
|
|
|
44
46
|
/**
|
|
@@ -85,7 +87,7 @@ ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
|
|
|
85
87
|
if (hasNativeMap) {
|
|
86
88
|
var idx = this._set.get(aStr);
|
|
87
89
|
if (idx >= 0) {
|
|
88
|
-
|
|
90
|
+
return idx;
|
|
89
91
|
}
|
|
90
92
|
} else {
|
|
91
93
|
var sStr = util.toSetString(aStr);
|
|
@@ -67,9 +67,7 @@ var VLQ_CONTINUATION_BIT = VLQ_BASE;
|
|
|
67
67
|
* 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
|
|
68
68
|
*/
|
|
69
69
|
function toVLQSigned(aValue) {
|
|
70
|
-
return aValue < 0
|
|
71
|
-
? ((-aValue) << 1) + 1
|
|
72
|
-
: (aValue << 1) + 0;
|
|
70
|
+
return aValue < 0 ? (-aValue << 1) + 1 : (aValue << 1) + 0;
|
|
73
71
|
}
|
|
74
72
|
|
|
75
73
|
/**
|
|
@@ -81,16 +79,14 @@ function toVLQSigned(aValue) {
|
|
|
81
79
|
function fromVLQSigned(aValue) {
|
|
82
80
|
var isNegative = (aValue & 1) === 1;
|
|
83
81
|
var shifted = aValue >> 1;
|
|
84
|
-
return isNegative
|
|
85
|
-
? -shifted
|
|
86
|
-
: shifted;
|
|
82
|
+
return isNegative ? -shifted : shifted;
|
|
87
83
|
}
|
|
88
84
|
|
|
89
85
|
/**
|
|
90
86
|
* Returns the base 64 VLQ encoded value.
|
|
91
87
|
*/
|
|
92
88
|
exports.encode = function base64VLQ_encode(aValue) {
|
|
93
|
-
var encoded =
|
|
89
|
+
var encoded = '';
|
|
94
90
|
var digit;
|
|
95
91
|
|
|
96
92
|
var vlq = toVLQSigned(aValue);
|
|
@@ -121,12 +117,12 @@ exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
|
|
|
121
117
|
|
|
122
118
|
do {
|
|
123
119
|
if (aIndex >= strLen) {
|
|
124
|
-
throw new Error(
|
|
120
|
+
throw new Error('Expected more digits in base 64 VLQ value.');
|
|
125
121
|
}
|
|
126
122
|
|
|
127
123
|
digit = base64.decode(aStr.charCodeAt(aIndex++));
|
|
128
124
|
if (digit === -1) {
|
|
129
|
-
throw new Error(
|
|
125
|
+
throw new Error('Invalid base64 digit: ' + aStr.charAt(aIndex - 1));
|
|
130
126
|
}
|
|
131
127
|
|
|
132
128
|
continuation = !!(digit & VLQ_CONTINUATION_BIT);
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* http://opensource.org/licenses/BSD-3-Clause
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
var intToCharMap =
|
|
8
|
+
var intToCharMap =
|
|
9
|
+
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Encode an integer in the range of 0 to 63 to a single base 64 digit.
|
|
@@ -14,7 +15,7 @@ exports.encode = function (number) {
|
|
|
14
15
|
if (0 <= number && number < intToCharMap.length) {
|
|
15
16
|
return intToCharMap[number];
|
|
16
17
|
}
|
|
17
|
-
throw new TypeError(
|
|
18
|
+
throw new TypeError('Must be between 0 and 63: ' + number);
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -22,34 +23,34 @@ exports.encode = function (number) {
|
|
|
22
23
|
* failure.
|
|
23
24
|
*/
|
|
24
25
|
exports.decode = function (charCode) {
|
|
25
|
-
var bigA = 65;
|
|
26
|
-
var bigZ = 90;
|
|
26
|
+
var bigA = 65; // 'A'
|
|
27
|
+
var bigZ = 90; // 'Z'
|
|
27
28
|
|
|
28
|
-
var littleA = 97;
|
|
29
|
+
var littleA = 97; // 'a'
|
|
29
30
|
var littleZ = 122; // 'z'
|
|
30
31
|
|
|
31
|
-
var zero = 48;
|
|
32
|
-
var nine = 57;
|
|
32
|
+
var zero = 48; // '0'
|
|
33
|
+
var nine = 57; // '9'
|
|
33
34
|
|
|
34
|
-
var plus = 43;
|
|
35
|
-
var slash = 47;
|
|
35
|
+
var plus = 43; // '+'
|
|
36
|
+
var slash = 47; // '/'
|
|
36
37
|
|
|
37
38
|
var littleOffset = 26;
|
|
38
39
|
var numberOffset = 52;
|
|
39
40
|
|
|
40
41
|
// 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
|
41
42
|
if (bigA <= charCode && charCode <= bigZ) {
|
|
42
|
-
return
|
|
43
|
+
return charCode - bigA;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
// 26 - 51: abcdefghijklmnopqrstuvwxyz
|
|
46
47
|
if (littleA <= charCode && charCode <= littleZ) {
|
|
47
|
-
return
|
|
48
|
+
return charCode - littleA + littleOffset;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
// 52 - 61: 0123456789
|
|
51
52
|
if (zero <= charCode && charCode <= nine) {
|
|
52
|
-
return
|
|
53
|
+
return charCode - zero + numberOffset;
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
// 62: +
|
|
@@ -36,8 +36,7 @@ function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
|
|
|
36
36
|
if (cmp === 0) {
|
|
37
37
|
// Found the element we are looking for.
|
|
38
38
|
return mid;
|
|
39
|
-
}
|
|
40
|
-
else if (cmp > 0) {
|
|
39
|
+
} else if (cmp > 0) {
|
|
41
40
|
// Our needle is greater than aHaystack[mid].
|
|
42
41
|
if (aHigh - mid > 1) {
|
|
43
42
|
// The element is in the upper half.
|
|
@@ -51,8 +50,7 @@ function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
|
|
|
51
50
|
} else {
|
|
52
51
|
return mid;
|
|
53
52
|
}
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
53
|
+
} else {
|
|
56
54
|
// Our needle is less than aHaystack[mid].
|
|
57
55
|
if (mid - aLow > 1) {
|
|
58
56
|
// The element is in the lower half.
|
|
@@ -91,8 +89,14 @@ exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
|
|
|
91
89
|
return -1;
|
|
92
90
|
}
|
|
93
91
|
|
|
94
|
-
var index = recursiveSearch(
|
|
95
|
-
|
|
92
|
+
var index = recursiveSearch(
|
|
93
|
+
-1,
|
|
94
|
+
aHaystack.length,
|
|
95
|
+
aNeedle,
|
|
96
|
+
aHaystack,
|
|
97
|
+
aCompare,
|
|
98
|
+
aBias || exports.GREATEST_LOWER_BOUND
|
|
99
|
+
);
|
|
96
100
|
if (index < 0) {
|
|
97
101
|
return -1;
|
|
98
102
|
}
|
|
@@ -17,8 +17,11 @@ function generatedPositionAfter(mappingA, mappingB) {
|
|
|
17
17
|
var lineB = mappingB.generatedLine;
|
|
18
18
|
var columnA = mappingA.generatedColumn;
|
|
19
19
|
var columnB = mappingB.generatedColumn;
|
|
20
|
-
return
|
|
21
|
-
|
|
20
|
+
return (
|
|
21
|
+
lineB > lineA ||
|
|
22
|
+
(lineB == lineA && columnB >= columnA) ||
|
|
23
|
+
util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0
|
|
24
|
+
);
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
/**
|
|
@@ -30,7 +33,7 @@ function MappingList() {
|
|
|
30
33
|
this._array = [];
|
|
31
34
|
this._sorted = true;
|
|
32
35
|
// Serves as infimum
|
|
33
|
-
this._last = {generatedLine: -1, generatedColumn: 0};
|
|
36
|
+
this._last = { generatedLine: -1, generatedColumn: 0 };
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
/**
|
|
@@ -39,10 +42,12 @@ function MappingList() {
|
|
|
39
42
|
*
|
|
40
43
|
* NOTE: The order of the mappings is NOT guaranteed.
|
|
41
44
|
*/
|
|
42
|
-
MappingList.prototype.unsortedForEach =
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
MappingList.prototype.unsortedForEach = function MappingList_forEach(
|
|
46
|
+
aCallback,
|
|
47
|
+
aThisArg
|
|
48
|
+
) {
|
|
49
|
+
this._array.forEach(aCallback, aThisArg);
|
|
50
|
+
};
|
|
46
51
|
|
|
47
52
|
/**
|
|
48
53
|
* Add the given source mapping.
|
|
@@ -14,8 +14,18 @@
|
|
|
14
14
|
// fact, when sorting with a comparator, these costs outweigh the benefits of
|
|
15
15
|
// sorting in C++. By using our own JS-implemented Quick Sort (below), we get
|
|
16
16
|
// a ~3500ms mean speed-up in `bench/bench.html`.
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
//
|
|
18
|
+
// That only pays off while the JIT can inline the comparator, i.e. while the
|
|
19
|
+
// comparator call site in the sort sees a single comparator. The library sorts
|
|
20
|
+
// with four different comparators, so each one gets its own copy of the sort
|
|
21
|
+
// function (`doQuickSort0` .. `doQuickSort3` below). The copies have to be
|
|
22
|
+
// separate function literals in the source: closures created from the same
|
|
23
|
+
// literal share type feedback, and so did copies cloned with `new Function`
|
|
24
|
+
// from identical source text. Cloning with `new Function` also violates
|
|
25
|
+
// Content Security Policies that don't allow 'unsafe-eval', so the copies are
|
|
26
|
+
// written out by hand. Keep them identical. See:
|
|
27
|
+
// https://github.com/7rulnik/source-map-js/pull/29
|
|
28
|
+
// https://github.com/7rulnik/source-map-js/issues/81
|
|
19
29
|
|
|
20
30
|
/**
|
|
21
31
|
* Swap the elements indexed by `x` and `y` in the array `ary`.
|
|
@@ -42,7 +52,7 @@ function swap(ary, x, y) {
|
|
|
42
52
|
* The upper bound on the range.
|
|
43
53
|
*/
|
|
44
54
|
function randomIntInRange(low, high) {
|
|
45
|
-
return Math.round(low +
|
|
55
|
+
return Math.round(low + Math.random() * (high - low));
|
|
46
56
|
}
|
|
47
57
|
|
|
48
58
|
/**
|
|
@@ -57,7 +67,7 @@ function randomIntInRange(low, high) {
|
|
|
57
67
|
* @param {Number} r
|
|
58
68
|
* End index of the array
|
|
59
69
|
*/
|
|
60
|
-
function
|
|
70
|
+
function doQuickSort0(ary, comparator, p, r) {
|
|
61
71
|
// If our lower bound is less than our upper bound, we (1) partition the
|
|
62
72
|
// array into two pieces and (2) recurse on each half. If it is not, this is
|
|
63
73
|
// the empty array and our base case.
|
|
@@ -98,28 +108,85 @@ function doQuickSort(ary, comparator, p, r) {
|
|
|
98
108
|
|
|
99
109
|
// (2) Recurse on each half.
|
|
100
110
|
|
|
101
|
-
|
|
102
|
-
|
|
111
|
+
doQuickSort0(ary, comparator, p, q - 1);
|
|
112
|
+
doQuickSort0(ary, comparator, q + 1, r);
|
|
103
113
|
}
|
|
104
114
|
}
|
|
105
115
|
|
|
106
|
-
|
|
116
|
+
// Identical copies of `doQuickSort0`, see the comment at the top of the file.
|
|
117
|
+
|
|
118
|
+
function doQuickSort1(ary, comparator, p, r) {
|
|
119
|
+
if (p < r) {
|
|
120
|
+
var pivotIndex = randomIntInRange(p, r);
|
|
121
|
+
var i = p - 1;
|
|
122
|
+
|
|
123
|
+
swap(ary, pivotIndex, r);
|
|
124
|
+
var pivot = ary[r];
|
|
125
|
+
|
|
126
|
+
for (var j = p; j < r; j++) {
|
|
127
|
+
if (comparator(ary[j], pivot, false) <= 0) {
|
|
128
|
+
i += 1;
|
|
129
|
+
swap(ary, i, j);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
swap(ary, i + 1, j);
|
|
134
|
+
var q = i + 1;
|
|
135
|
+
|
|
136
|
+
doQuickSort1(ary, comparator, p, q - 1);
|
|
137
|
+
doQuickSort1(ary, comparator, q + 1, r);
|
|
138
|
+
}
|
|
107
139
|
}
|
|
108
140
|
|
|
109
|
-
function
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
141
|
+
function doQuickSort2(ary, comparator, p, r) {
|
|
142
|
+
if (p < r) {
|
|
143
|
+
var pivotIndex = randomIntInRange(p, r);
|
|
144
|
+
var i = p - 1;
|
|
145
|
+
|
|
146
|
+
swap(ary, pivotIndex, r);
|
|
147
|
+
var pivot = ary[r];
|
|
148
|
+
|
|
149
|
+
for (var j = p; j < r; j++) {
|
|
150
|
+
if (comparator(ary[j], pivot, false) <= 0) {
|
|
151
|
+
i += 1;
|
|
152
|
+
swap(ary, i, j);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
swap(ary, i + 1, j);
|
|
157
|
+
var q = i + 1;
|
|
158
|
+
|
|
159
|
+
doQuickSort2(ary, comparator, p, q - 1);
|
|
160
|
+
doQuickSort2(ary, comparator, q + 1, r);
|
|
161
|
+
}
|
|
113
162
|
}
|
|
114
163
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
164
|
+
function doQuickSort3(ary, comparator, p, r) {
|
|
165
|
+
if (p < r) {
|
|
166
|
+
var pivotIndex = randomIntInRange(p, r);
|
|
167
|
+
var i = p - 1;
|
|
168
|
+
|
|
169
|
+
swap(ary, pivotIndex, r);
|
|
170
|
+
var pivot = ary[r];
|
|
171
|
+
|
|
172
|
+
for (var j = p; j < r; j++) {
|
|
173
|
+
if (comparator(ary[j], pivot, false) <= 0) {
|
|
174
|
+
i += 1;
|
|
175
|
+
swap(ary, i, j);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
swap(ary, i + 1, j);
|
|
180
|
+
var q = i + 1;
|
|
181
|
+
|
|
182
|
+
doQuickSort3(ary, comparator, p, q - 1);
|
|
183
|
+
doQuickSort3(ary, comparator, q + 1, r);
|
|
121
184
|
}
|
|
122
|
-
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
var sortCopies = [doQuickSort0, doQuickSort1, doQuickSort2, doQuickSort3];
|
|
188
|
+
var nextSortCopy = 0;
|
|
189
|
+
var sortCache = new WeakMap();
|
|
123
190
|
|
|
124
191
|
/**
|
|
125
192
|
* Sort the given array in-place with the given comparator function.
|
|
@@ -128,13 +195,16 @@ let isEvalAllowed = (function () {
|
|
|
128
195
|
* An array to sort.
|
|
129
196
|
* @param {function} comparator
|
|
130
197
|
* Function to use to compare two items.
|
|
198
|
+
* @param {Number} start
|
|
199
|
+
* Index to start sorting from; items before it are left untouched.
|
|
131
200
|
*/
|
|
132
|
-
|
|
133
|
-
let sortCache = new WeakMap();
|
|
134
201
|
exports.quickSort = function (ary, comparator, start = 0) {
|
|
135
|
-
|
|
136
|
-
if (doQuickSort ===
|
|
137
|
-
|
|
202
|
+
var doQuickSort = sortCache.get(comparator);
|
|
203
|
+
if (doQuickSort === undefined) {
|
|
204
|
+
// Each comparator claims the next free copy. Should there ever be more
|
|
205
|
+
// comparators than copies, the extra ones share the last copy: still
|
|
206
|
+
// correct, just slower for the comparators sharing it.
|
|
207
|
+
doQuickSort = sortCopies[Math.min(nextSortCopy++, sortCopies.length - 1)];
|
|
138
208
|
sortCache.set(comparator, doQuickSort);
|
|
139
209
|
}
|
|
140
210
|
doQuickSort(ary, comparator, start, ary.length - 1);
|