cuprate
cuprate copied to clipboard
[Database] small edits to resize.rs
- Changed "0.0000082s" to "8.2µs" because its clearer imo
- Removed
pub
marker to free functions
This fails to compile as the functions are private, they could be made pub(crate)
This fails to compile as the functions are private, they could be made pub(crate)
My bad. I didn't see heed/env.rs using fixed_bytes()
. Why not replace:
// Add leeway space.
let memory_map_size = crate::resize::fixed_bytes(disk_size_bytes, 1_000_000 /* 1MB */);
env_open_options.map_size(memory_map_size.get());
by
// Add leeway space.
let memory_map_size = ResizeAlgorithm::FixedBytes(NonZeroUsize::new(1_000_000usize).unwrap()).resize(disk_size_bytes); // Import crate::resize::ResizeAlgorithm.
env_open_options.map_size(memory_map_size.get());
This seems like the intended semantic here
Is there a reason why these can't be pub
? If they aren't necessary then the free functions should be inlined into ResizeAlgorithm
+ doc-tests should be moved to the appropriate variant:
pub enum ResizeAlgorithm {
/// <insert [`monero`] doctest>
Monero,
/// <insert [`fixed_bytes`] doctest>
FixedBytes(NonZeroUsize),
/// <insert [`percent`] doctest>
Percent(f32),
}
impl ResizeAlgorithm {
// remove #[inline], too big
pub fn resize(&self, current_size_bytes: usize) -> NonZeroUsize {
match self {
Self::Monero => /* inlined monero(current_size_bytes) */,
Self::FixedBytes(add_bytes) => // etc,
Self::Percent(f) => // etc,
}
}
}
My bad. I didn't see heed/env.rs using fixed_bytes(). Why not replace:
Yeah that could work too.
@SyntheticBird45 is this this still something you want, IMO these are ok being pub
lmao nah no need to resolve conflict for that