From 5a13a5416e2442d8048b132c1423ab7c35c58066 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 15 Jan 2020 22:09:45 +0100 Subject: [PATCH] Kernel: Avoid an extra call to read_bytes() in Inode::read_entire() If we slurp up the entire inode in a single read_bytes(), no need to call read_bytes() again. --- Kernel/FileSystem/Inode.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Kernel/FileSystem/Inode.cpp b/Kernel/FileSystem/Inode.cpp index 64c407ad07..e04de87fea 100644 --- a/Kernel/FileSystem/Inode.cpp +++ b/Kernel/FileSystem/Inode.cpp @@ -45,6 +45,8 @@ ByteBuffer Inode::read_entire(FileDescription* descriptor) const break; builder.append((const char*)buffer, nread); offset += nread; + if (nread < (ssize_t)sizeof(buffer)) + break; } if (nread < 0) { kprintf("Inode::read_entire: ERROR: %d\n", nread);