Store a value, choosing inline or overflow based on the threshold.
(
overflow: &mut SlabAllocator,
value: &[u8],
inline_threshold: usize,
)
| 87 | |
| 88 | /// Store a value, choosing inline or overflow based on the threshold. |
| 89 | pub(super) fn store_value_in( |
| 90 | overflow: &mut SlabAllocator, |
| 91 | value: &[u8], |
| 92 | inline_threshold: usize, |
| 93 | ) -> KvValue { |
| 94 | if value.len() <= inline_threshold { |
| 95 | KvValue::Inline(value.to_vec()) |
| 96 | } else { |
| 97 | let (index, len) = overflow.alloc(value); |
| 98 | KvValue::Overflow { index, len } |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | /// Free overflow storage if the value is an overflow entry. |
| 103 | pub(super) fn free_value_from(value: &KvValue, overflow: &mut SlabAllocator) { |