avoid unnecessary allocations

This commit is contained in:
Nikita Sivukhin
2025-10-21 18:30:08 +04:00
parent d2d995a9c0
commit 00e382a7c7

View File

@@ -239,13 +239,13 @@ impl PoolInner {
.wal_frame_arena
.as_ref()
.and_then(|wal_arena| Arena::try_alloc(wal_arena, len))
.unwrap_or(Buffer::new_temporary(len));
.unwrap_or_else(|| Buffer::new_temporary(len));
}
// For all other sizes, use regular arena
self.page_arena
.as_ref()
.and_then(|arena| Arena::try_alloc(arena, len))
.unwrap_or(Buffer::new_temporary(len))
.unwrap_or_else(|| Buffer::new_temporary(len))
}
fn get_db_page_buffer(&mut self) -> Buffer {
@@ -253,7 +253,7 @@ impl PoolInner {
self.page_arena
.as_ref()
.and_then(|arena| Arena::try_alloc(arena, db_page_size))
.unwrap_or(Buffer::new_temporary(db_page_size))
.unwrap_or_else(|| Buffer::new_temporary(db_page_size))
}
fn get_wal_frame_buffer(&mut self) -> Buffer {
@@ -261,7 +261,7 @@ impl PoolInner {
self.wal_frame_arena
.as_ref()
.and_then(|wal_arena| Arena::try_alloc(wal_arena, len))
.unwrap_or(Buffer::new_temporary(len))
.unwrap_or_else(|| Buffer::new_temporary(len))
}
/// Allocate a new arena for the pool to use