diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-02-24 13:11:50 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-02-24 13:35:53 -0400 |
commit | f78074bf722c4c88ff0914ee71028c2fbfd2a754 (patch) | |
tree | 8369163db498434674fbd8c0bcc2c0564f6097dd | |
parent | 604105d430056f9e015612d27981efbca04a1d0f (diff) |
data: withSortedList: general syntax cleanup
-rw-r--r-- | src/data/composite/data/withSortedList.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/data/composite/data/withSortedList.js b/src/data/composite/data/withSortedList.js index 6b67f57e..81a06e76 100644 --- a/src/data/composite/data/withSortedList.js +++ b/src/data/composite/data/withSortedList.js @@ -54,13 +54,10 @@ export default templateCompositeFrom({ [input('list')]: list, [input('sort')]: sortFn, }) { - const originalIndices = - Array.from({length: list.length}, (_, index) => index); - const symbols = []; const symbolToIndex = new Map(); - for (const index of originalIndices) { + for (const index of list.keys()) { const symbol = Symbol(); symbols.push(symbol); symbolToIndex.set(symbol, index); @@ -104,8 +101,11 @@ export default templateCompositeFrom({ stableSortIndices.push(sourceIndex); sortedList.push(list[sourceIndex]); - if (stableIndex > 0 && !isEqual(symbol, symbols[stableIndex - 1])) { - unstableIndex++; + if (stableIndex > 0) { + const previous = symbols[stableIndex - 1]; + if (!isEqual(symbol, previous)) { + unstableIndex++; + } } unstableSortIndices[sourceIndex] = unstableIndex; |