Skip to content

Commit

Permalink
style: rename
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleSound committed Aug 19, 2024
1 parent ed45f05 commit 91e12cc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions benchmark/client/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ async function bench() {
// Reduce the complexity of `selected` from O(n) to O(1).
function createSelector(source: WatchSource) {
const list: Record<keyof any, ShallowRef<boolean>> = {}
const cache: Record<keyof any, ShallowRef<boolean>> = {}
watch(source, (val, old) => {
if (old != undefined) list[old]!.value = false
if (val != undefined) list[val]!.value = true
if (old != undefined) cache[old]!.value = false
if (val != undefined) cache[val]!.value = true
})
return (id: keyof any) => (list[id] ??= shallowRef(false)).value
return (id: keyof any) => (cache[id] ??= shallowRef(false)).value
}
const isSelected = createSelector(selected)
Expand Down

0 comments on commit 91e12cc

Please sign in to comment.