Fix leaks of WeakVec (#6576)

This commit is contained in:
Xiaopeng Li 2024-11-21 17:47:05 +08:00 committed by GitHub
parent 00a6032eb7
commit 5ca92bf984
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -47,7 +47,7 @@ impl<T> WeakVec<T> {
} }
if let Some(i) = self.empty_slots.pop() { if let Some(i) = self.empty_slots.pop() {
self.inner[i] = Some(value); self.inner[i] = Some(value);
self.scan_slots_on_next_push = false; self.scan_slots_on_next_push = self.empty_slots.is_empty();
} else { } else {
self.inner.push(Some(value)); self.inner.push(Some(value));
self.scan_slots_on_next_push = self.inner.len() == self.inner.capacity(); self.scan_slots_on_next_push = self.inner.len() == self.inner.capacity();