From 9c373b646b64ab23f8fdda35177c861d0a9c1cf2 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 15 Aug 2021 18:58:50 +0200 Subject: [PATCH] Kernel/SysFS: Don't compute exact size of PCI files There's no need for generated files in SysFS to tell you their precise file size when you stat() them. I noticed when profiling "find /" that we were spending a chunk of time generating and throwing away SysFS content just so we could tell you exactly how large it would be. :^) --- Kernel/Bus/PCI/Access.cpp | 8 -------- Kernel/Bus/PCI/Access.h | 1 - 2 files changed, 9 deletions(-) diff --git a/Kernel/Bus/PCI/Access.cpp b/Kernel/Bus/PCI/Access.cpp index 2c2be5c606..b99a58808a 100644 --- a/Kernel/Bus/PCI/Access.cpp +++ b/Kernel/Bus/PCI/Access.cpp @@ -430,14 +430,6 @@ KResultOr PCIDeviceAttributeSysFSComponent::read_bytes(off_t offset, siz return nread; } -size_t PCIDeviceAttributeSysFSComponent::size() const -{ - auto buffer = try_to_generate_buffer(); - if (!buffer) - return 0; - return buffer->size(); -} - OwnPtr PCIDeviceAttributeSysFSComponent::try_to_generate_buffer() const { String value; diff --git a/Kernel/Bus/PCI/Access.h b/Kernel/Bus/PCI/Access.h index e0e48b8406..6d1b3fc3eb 100644 --- a/Kernel/Bus/PCI/Access.h +++ b/Kernel/Bus/PCI/Access.h @@ -39,7 +39,6 @@ public: virtual KResultOr read_bytes(off_t, size_t, UserOrKernelBuffer&, FileDescription*) const override; virtual ~PCIDeviceAttributeSysFSComponent() {}; - virtual size_t size() const override; protected: virtual OwnPtr try_to_generate_buffer() const;