From a412fd2ed88a796451eb799014c67c125085ceb4 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 15 Aug 2021 19:00:33 +0200 Subject: [PATCH] Kernel/ProcFS: Avoid two unnecessary number-to-string conversions We don't need to create a new string from a number in order to compare an existing string to that number. Converting the existing string to a number is much cheaper, since it does not require any heap allocations. Ran into this while profiling "find /" :^) --- Kernel/ProcessSpecificExposed.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel/ProcessSpecificExposed.cpp b/Kernel/ProcessSpecificExposed.cpp index 03a53882fe..b71295887c 100644 --- a/Kernel/ProcessSpecificExposed.cpp +++ b/Kernel/ProcessSpecificExposed.cpp @@ -61,7 +61,7 @@ KResultOr> Process::lookup_stacks_directory(const ProcFS& p for_each_thread([&](const Thread& thread) { int tid = thread.tid().value(); VERIFY(!(tid < 0)); - if (name == String::number(tid)) { + if (name.to_int() == tid) { auto maybe_inode = ProcFSProcessPropertyInode::try_create_for_thread_stack(procfs, thread.tid(), pid()); if (maybe_inode.is_error()) { thread_stack_inode = maybe_inode.error(); @@ -114,7 +114,7 @@ KResultOr> Process::lookup_file_descriptions_directory(cons count++; return; } - if (name == String::number(count)) { + if (name.to_uint() == count) { auto maybe_inode = ProcFSProcessPropertyInode::try_create_for_file_description_link(procfs, static_cast(count), pid()); if (maybe_inode.is_error()) { file_description_link = maybe_inode.error();