From f78074bf722c4c88ff0914ee71028c2fbfd2a754 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 24 Feb 2024 13:11:50 -0400 Subject: data: withSortedList: general syntax cleanup --- src/data/composite/data/withSortedList.js | 12 ++++++------ 1 file 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; -- cgit 1.3.0-6-gf8a5