MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / tier_index

Function tier_index

nodedb/src/engine/kv/slab.rs:338–346  ·  view source on GitHub ↗

Find the tier index for a given value size. Returns the index of the smallest tier that can hold `size` bytes.

(size: usize)

Source from the content-addressed store, hash-verified

336///
337/// Returns the index of the smallest tier that can hold `size` bytes.
338fn tier_index(size: usize) -> usize {
339 for (i, &tier_size) in TIER_SIZES.iter().enumerate() {
340 if size <= tier_size {
341 return i;
342 }
343 }
344 // Should not reach here for sizes <= MAX_SLAB_SIZE.
345 TIER_SIZES.len() - 1
346}
347
348#[cfg(test)]
349mod tests {

Callers 1

allocMethod · 0.85

Calls 2

iterMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected