Changeset 216137 in webkit
- Timestamp:
- May 3, 2017 1:33:01 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r216090 r216137 1 2017-05-03 Keith Miller <keith_miller@apple.com> 2 3 Different behaviour with the .sort(callback) method (unlike Firefox & Chrome) 4 https://bugs.webkit.org/show_bug.cgi?id=47825 5 6 Reviewed by Saam Barati. 7 8 * stress/sorting-boolean-result-comparator.js: Added. 9 (checkArray): 10 1 11 2017-05-02 David Kilzer <ddkilzer@apple.com> 2 12 -
trunk/LayoutTests/ChangeLog
r216136 r216137 1 2017-05-03 Keith Miller <keith_miller@apple.com> 2 3 Different behaviour with the .sort(callback) method (unlike Firefox & Chrome) 4 https://bugs.webkit.org/show_bug.cgi?id=47825 5 6 Reviewed by Saam Barati. 7 8 Fix broken test. 9 10 * http/tests/inspector/worker/blob-script-with-cross-domain-imported-scripts-expected.txt: 11 1 12 2017-05-03 Matt Lewis <jlewis3@apple.com> 2 13 -
trunk/LayoutTests/http/tests/inspector/worker/blob-script-with-cross-domain-imported-scripts-expected.txt
r210279 r216137 9 9 http://localhost:8000/inspector/worker/resources/worker-blob-import-script.js 10 10 SCRIPTS: 11 blob:<sanitized>12 11 http://localhost:8000/inspector/worker/resources/worker-blob-script.js 13 12 http://localhost:8000/inspector/worker/resources/worker-blob-import-script.js 13 blob:<sanitized> 14 14 -
trunk/Source/JavaScriptCore/ChangeLog
r216122 r216137 1 2017-05-03 Keith Miller <keith_miller@apple.com> 2 3 Different behaviour with the .sort(callback) method (unlike Firefox & Chrome) 4 https://bugs.webkit.org/show_bug.cgi?id=47825 5 6 Reviewed by Saam Barati. 7 8 This patch makes our sort function match the behavior of Firefox 9 and Chrome when the result of the comparison function is a 10 boolean. When we first switched to using merge sort, it regressed 11 JQuery sorting of DOM nodes by 30%. The regression was do to the 12 fact that JQuery was using compareDocumentPosition to compare the 13 locations of objects. Since one of the benchmarks would pass a 14 reverse sorted list to the sort function we would end up walking 15 the entire DOM to do comparisons. The solution to this was to 16 merge based on comparison(right, left) rather than 17 comparison(left, right). Although, in practice this does nothing 18 since sort could just as easily receive an already sorted list and 19 we're back in the same spot. 20 21 The downside of sorting with comparison(right, left) is that to 22 maintain stability when sorting, you only want to merge from right 23 when the comparison function returns a negative value. This is 24 where the problem with booleans comes in. Since booleans toNumber 25 false to 0 and true to 1 both values are "equal". This patch fixes 26 this by special casing boolean return values. 27 28 29 * builtins/ArrayPrototype.js: 30 (sort.merge): 31 1 32 2017-05-03 Andy VanWagoner <thetalecrafter@gmail.com> 2 33 -
trunk/Source/JavaScriptCore/builtins/ArrayPrototype.js
r212019 r216137 544 544 for (var dstIndex = left; dstIndex < rightEnd; ++dstIndex) { 545 545 if (right < rightEnd) { 546 if (left >= leftEnd || comparator(src[right], src[left]) < 0) {546 if (left >= leftEnd) { 547 547 dst[dstIndex] = src[right++]; 548 548 continue; 549 549 } 550 551 let comparisonResult = comparator(src[right], src[left]); 552 if ((typeof comparisonResult === "boolean" && !comparisonResult) || comparisonResult < 0) { 553 dst[dstIndex] = src[right++]; 554 continue; 555 } 556 550 557 } 551 558
Note: See TracChangeset
for help on using the changeset viewer.