mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-12 03:34:20 +01:00
add usable_space to DatabaseHeader
we already have the `DatabaseHeader`, we don't need the cached result
This commit is contained in:
@@ -1422,7 +1422,7 @@ impl Pager {
|
||||
|
||||
// Reserve 2 slots for the trunk page header which is 8 bytes or 2*LEAF_ENTRY_SIZE
|
||||
let max_free_list_entries =
|
||||
(self.usable_space() / LEAF_ENTRY_SIZE) - RESERVED_SLOTS;
|
||||
(header.usable_space() / LEAF_ENTRY_SIZE) - RESERVED_SLOTS;
|
||||
|
||||
if number_of_leaf_pages < max_free_list_entries as u32 {
|
||||
turso_assert!(
|
||||
|
||||
@@ -276,6 +276,10 @@ impl DatabaseHeader {
|
||||
const _CHECK: () = {
|
||||
assert!(Self::SIZE == 100);
|
||||
};
|
||||
|
||||
pub fn usable_space(self) -> usize {
|
||||
(self.page_size.get() as usize) - (self.reserved_space as usize)
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for DatabaseHeader {
|
||||
|
||||
Reference in New Issue
Block a user