Skip to content

Commit

Permalink
[TimSort] performance
Browse files Browse the repository at this point in the history
  • Loading branch information
lucher authored Jan 1, 2024
1 parent 21d2c25 commit 0f0f798
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/main/java/cn/nextop/TimArrSort.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ private void set(T s) { /* for write */

private void prev(int n) { /* for read */
int[] l = this.lens; int i = index - n;
if (hitCache(i)) return;/* cache hit */
if (this.row > 0) if (i < l[row - 1]) {
do { this.row--; } /* change row */
while ( row > 0 && i < l[row - 1] );
Expand All @@ -280,7 +279,6 @@ private void prev2(int n) { /* for write */

private void next(int n) { /* for read */
int i = this.index + n;
if (hitCache(i)) return;
if (i >= this.lens[row]) {
do { this.row++; }/*!*/
while (i >= lens[row]);
Expand Down Expand Up @@ -311,6 +309,7 @@ private void skipEmpty() { /* skip */

private void locate(int i) { /* for read */
if (i == index) return;
if (hitCache(i)) return;
int n = abs(i - this.index);
final boolean b = i > index;
if (b) next(n); else prev(n);
Expand Down

0 comments on commit 0f0f798

Please sign in to comment.