Skip to content

Commit ab7ceb8

Browse files
megothssNullVoxPopuli
authored andcommitted
Review feedback: rename and docs
Rename `existing` → `hasExisting` in set() and clarify iterator tag entanglement in JSDoc
1 parent ea8c64d commit ab7ceb8

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

packages/@glimmer/validator/lib/collections/map.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@ class TrackedMap<K = unknown, V = unknown> implements Map<K, V> {
107107

108108
/**
109109
* When iterating:
110-
* - we entangle with the collection (as we iterate over the whole thing
110+
* - we entangle with the collection (as we iterate over the whole thing)
111+
* via keys() → consumeTag(#collection)
111112
* - for each individual item, we entangle with the item as well
113+
* via get() → consumeTag(#storageFor(key))
112114
*/
113115
[Symbol.iterator]() {
114116
let keys = this.keys();
@@ -138,9 +140,9 @@ class TrackedMap<K = unknown, V = unknown> implements Map<K, V> {
138140
}
139141

140142
set(key: K, value: V): this {
141-
let existing = this.#vals.has(key);
143+
let hasExisting = this.#vals.has(key);
142144

143-
if (existing) {
145+
if (hasExisting) {
144146
let isUnchanged = this.#options.equals(this.#vals.get(key) as V, value);
145147

146148
if (isUnchanged) {
@@ -150,7 +152,7 @@ class TrackedMap<K = unknown, V = unknown> implements Map<K, V> {
150152

151153
this.#dirtyStorageFor(key);
152154

153-
if (!existing) {
155+
if (!hasExisting) {
154156
DIRTY_TAG(this.#collection);
155157
}
156158

packages/@glimmer/validator/lib/collections/weak-map.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ class TrackedWeakMap<K extends WeakKey = object, V = unknown> implements WeakMap
5151
}
5252

5353
set(key: K, value: V): this {
54-
let existing = this.#vals.has(key);
54+
let hasExisting = this.#vals.has(key);
5555

56-
if (existing) {
56+
if (hasExisting) {
5757
let isUnchanged = this.#options.equals(this.#vals.get(key) as V, value);
5858

5959
if (isUnchanged) {

0 commit comments

Comments
 (0)