Skip to content

Commit

Permalink
cached indexMap.has to index
Browse files Browse the repository at this point in the history
  • Loading branch information
overthemike committed Oct 12, 2024
1 parent 52f7afe commit caac109
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/vanilla/utils/proxyMap-indexMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ export function proxyMap<K, V>(entries?: Iterable<[K, V]> | undefined | null) {
},
get(key: K) {
const k = maybeProxify(key)
if (!indexMap.has(k) && !isProxy(this)) {
const index = indexMap.get(k)
if (index !== undefined && !isProxy(this)) {
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
this.data.length
}
if (indexMap.has(k)) {
if (index !== undefined) {
const index = indexMap.get(k)!
if (this.data[index] !== undefined) {
return this.data[index]![1]
Expand All @@ -50,11 +51,12 @@ export function proxyMap<K, V>(entries?: Iterable<[K, V]> | undefined | null) {
},
has(key: K) {
const k = maybeProxify(key)
if (!indexMap.has(k) && !isProxy(this)) {
const index = indexMap.get(k)
if (index !== undefined && !isProxy(this)) {
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
this.data.length
}
return indexMap.has(k)
return index !== undefined
},
set(key: K, value: V) {
if (!isProxy(this)) {
Expand Down

0 comments on commit caac109

Please sign in to comment.