Skip to content

Commit

Permalink
add debug assert to sure no case to call get_size recursively
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Nov 1, 2024
1 parent f8dd0ef commit 0a30558
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/storage/src/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ static GLOBAL: SizeCounterAllocator = SizeCounterAllocator;

#[inline]
fn start_metering() {
debug_assert!(!METERING.with(|metering| metering.get()));
SIZE.with(|size| size.set(0));
METERING.with(|metering| metering.set(true));
}

#[inline]
fn finish_metering() -> usize {
debug_assert!(METERING.with(|metering| metering.get()));
METERING.with(|metering| metering.set(false));
SIZE.with(|size| size.get())
}
Expand Down

0 comments on commit 0a30558

Please sign in to comment.