From 95af728e397b5440be323ca9a2739c107bc6e8aa Mon Sep 17 00:00:00 2001 From: Bananymous Date: Fri, 17 Nov 2023 19:02:01 +0200 Subject: [PATCH] Kernel: Don't calculate divisor in a for loop in ext2 inodes --- kernel/kernel/FS/Ext2/Inode.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/kernel/kernel/FS/Ext2/Inode.cpp b/kernel/kernel/FS/Ext2/Inode.cpp index 54a82ea663..c9104d0e09 100644 --- a/kernel/kernel/FS/Ext2/Inode.cpp +++ b/kernel/kernel/FS/Ext2/Inode.cpp @@ -56,9 +56,7 @@ namespace Kernel const uint32_t indices_per_block = blksize() / sizeof(uint32_t); - uint32_t divisor = 1; - for (uint32_t i = 1; i < depth; i++) - divisor *= indices_per_block; + const uint32_t divisor = (depth > 1) ? indices_per_block * (depth - 1) : 1; const uint32_t next_block = block_buffer.span().as_span()[(index / divisor) % indices_per_block]; if (next_block == 0)