summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2020-01-15 22:09:45 +0100
committerAndreas Kling <awesomekling@gmail.com>2020-01-15 22:11:44 +0100
commit5a13a5416e2442d8048b132c1423ab7c35c58066 (patch)
tree1d7a2da925211606bb4f08257cb662d9f5f2df76 /Kernel/FileSystem
parent09fd59a1b564e918be12f0419bc7134c6630f20d (diff)
downloadserenity-5a13a5416e2442d8048b132c1423ab7c35c58066.zip
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.
Diffstat (limited to 'Kernel/FileSystem')
-rw-r--r--Kernel/FileSystem/Inode.cpp2
1 files changed, 2 insertions, 0 deletions
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);