Skip to content

Commit 0d13e9c

Browse files
committed
fix and clean up hashmap get
1 parent 0c6a5d2 commit 0d13e9c

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

lib/hashmap.cb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,16 +229,16 @@ export function get(self, key) {
229229
let hashed = do_hash(self, key);
230230
let bucket = self.buckets[hashed];
231231

232-
if (bucket == null) {
233-
return null;
234-
}
235-
236232
while (bucket != null && (bucket == TOMBSTONE || bucket.key != key)) {
237233
hashed = next_hash(self, hashed);
238234
bucket = self.buckets[hashed];
239235
}
240236

241-
return bucket.value;
237+
if (bucket == null) {
238+
return null;
239+
} else {
240+
return bucket.value;
241+
}
242242
}
243243

244244
doc.add("function", "get(map, key)", "Get the value associated with `key` from `map`.");

0 commit comments

Comments
 (0)