diff --git a/src/internal/mapping.rs b/src/internal/mapping.rs index 26df86b..4655be0 100644 --- a/src/internal/mapping.rs +++ b/src/internal/mapping.rs @@ -60,7 +60,9 @@ impl Mapping { .resize_with(chunk + 1, || std::array::from_fn(|_| None)); } let previous_value = self.chunks[chunk][offset].replace(value); - self.len += 1; + if previous_value.is_none() { + self.len += 1; + } self.max = self.max.max(idx); previous_value }