Skip to content

Commit

Permalink
rename kv_heap_size to heap_size
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Chien <[email protected]>
  • Loading branch information
stdrc committed Mar 21, 2024
1 parent 2c18ce9 commit 7cef375
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/common/estimate_size/src/collections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ use crate::EstimateSize;
#[derive(Clone)]
pub struct EstimatedVec<T: EstimateSize> {
inner: Vec<T>,
kv_heap_size: usize,
heap_size: usize,
}

impl<T: EstimateSize> Default for EstimatedVec<T> {
fn default() -> Self {
Self {
inner: vec![],
kv_heap_size: 0,
heap_size: 0,
}
}
}

impl<T: EstimateSize> EstimateSize for EstimatedVec<T> {
fn estimated_heap_size(&self) -> usize {
self.kv_heap_size
self.heap_size
}
}

Expand All @@ -41,9 +41,7 @@ impl<T: EstimateSize> EstimatedVec<T> {
}

pub fn push(&mut self, value: T) {
self.kv_heap_size = self
.kv_heap_size
.saturating_add(value.estimated_heap_size());
self.heap_size = self.heap_size.saturating_add(value.estimated_heap_size());
self.inner.push(value);
}

Expand Down

0 comments on commit 7cef375

Please sign in to comment.