mirror of
https://github.com/SerenityOS/serenity
synced 2026-05-09 08:32:04 +02:00
In Ext2FSInode::compute_block_list_impl(), each call to process_block_array() creates a new ByteBuffer, which leads to a kmalloc() call. The ByteBuffer is then discarded when process_block_array() exits, leading to a kfree() call. This leads to repeated kmalloc() and kfree() calls as ByteBuffers are created and destroyed each time process_block_array() is called. This commit makes it so that only 1 ByteBuffer is created for each level of inode indirect block (so only 3 ByteBuffers are created at most). These ByteBuffers are re-used on each call to process_block_array(). This reduces the number of kmalloc() and kfree() calls during compute_block_list_impl(), especially for larger files.