Skip to content

Commit

Permalink
use copyWithin instead of loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans Acker committed Jan 9, 2025
1 parent 8703295 commit cdf7cc1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions html/js/statsbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,9 @@ class SortedStatsBox extends StatsBox {
this._rows[idxNew].tr.before(stat.tr); // move table row

// shift array back by one
while (idxOld > idxNew) {
this._rows[idxOld] = this._rows[idxOld-1];
idxOld--;
}
this._rows.copyWithin(idxNew+1, idxNew, idxOld);

// re-insert element
this._rows[idxNew] = stat;

//console.log(`${key}: ${this._stats[key]} => ${idxNew}`);
Expand Down
2 changes: 1 addition & 1 deletion html/js/statsbox.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cdf7cc1

Please sign in to comment.