Skip to content

Commit 6de0042

Browse files
authored
Merge pull request #3124 from plotly/lib-sort-update
update Lib.sort comment and relax its tests
2 parents 1a075ff + 55e6e86 commit 6de0042

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

Diff for: src/lib/search.js

+4
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ exports.roundUp = function(val, arrayIn, reverse) {
118118
/**
119119
* Tweak to Array.sort(sortFn) that improves performance for pre-sorted arrays
120120
*
121+
* Note that newer browsers (such as Chrome v70+) are starting to pick up
122+
* on pre-sorted arrays which may render the following optimization unnecessary
123+
* in the future.
124+
*
121125
* Motivation: sometimes we need to sort arrays but the input is likely to
122126
* already be sorted. Browsers don't seem to pick up on pre-sorted arrays,
123127
* and in fact Chrome is actually *slower* sorting pre-sorted arrays than purely

Diff for: test/jasmine/tests/lib_test.js

-8
Original file line numberDiff line numberDiff line change
@@ -2329,21 +2329,13 @@ describe('Test lib.js:', function() {
23292329
.toEqual(dupes());
23302330

23312331
expect(callCount).toEqual(18);
2332-
2333-
callCount = 0;
2334-
dupes().sort(sortCounter);
2335-
expect(callCount).toBeGreaterThan(18);
23362332
});
23372333

23382334
it('still short-circuits reversed with duplicates', function() {
23392335
expect(_sort(dupes(), sortCounterReversed))
23402336
.toEqual(dupes().reverse());
23412337

23422338
expect(callCount).toEqual(18);
2343-
2344-
callCount = 0;
2345-
dupes().sort(sortCounterReversed);
2346-
expect(callCount).toBeGreaterThan(18);
23472339
});
23482340
});
23492341

0 commit comments

Comments
 (0)