mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 06:48:49 +00:00
Kernel: Reduce ByteBuffer thrashing in inode block list generation
Instead of creating and destroying a new ByteBuffer for every block we process during block list generation, just use stack memory instead.
This commit is contained in:
parent
68abd1cb29
commit
76308c2e1f
Notes:
sideshowbarker
2024-07-19 01:16:58 +09:00
Author: https://github.com/awesomekling
Commit: 76308c2e1f
1 changed files with 4 additions and 7 deletions
|
@ -484,13 +484,10 @@ Vector<Ext2FS::BlockIndex> Ext2FS::block_list_for_inode_impl(const ext2_inode& e
|
|||
auto process_block_array = [&](unsigned array_block_index, auto&& callback) {
|
||||
if (include_block_list_blocks)
|
||||
add_block(array_block_index);
|
||||
unsigned count = min(blocks_remaining, entries_per_block);
|
||||
size_t read_size = count * sizeof(__u32);
|
||||
auto array_block = ByteBuffer::create_uninitialized(read_size);
|
||||
auto buffer = UserOrKernelBuffer::for_kernel_buffer(array_block.data());
|
||||
read_block(array_block_index, &buffer, read_size, 0);
|
||||
ASSERT(array_block);
|
||||
auto* array = reinterpret_cast<const __u32*>(array_block.data());
|
||||
auto count = min(blocks_remaining, entries_per_block);
|
||||
u32 array[count];
|
||||
auto buffer = UserOrKernelBuffer::for_kernel_buffer((u8*)array);
|
||||
read_block(array_block_index, &buffer, sizeof(array), 0);
|
||||
for (BlockIndex i = 0; i < count; ++i)
|
||||
callback(array[i]);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue