summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-12-30 14:50:40 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-12-30 14:51:34 +0100
commit1b2c6e8f41ae7f9c3db1d0e2b8d457689d48baaa (patch)
tree7493d0ac6d54a2ba1dbebf60f0fb10ebde402163 /Libraries
parent7011dba98e9616727a4d529fe4fda6a8ceefe393 (diff)
downloadserenity-1b2c6e8f41ae7f9c3db1d0e2b8d457689d48baaa.zip
LibCore: Use JsonObject::get_ptr() in CProcessStatisticsReader
This removes a bunch of JsonValue copying from the hot path in thread statistics fetching. Also pre-size the thread statistics vector since we know the final size up front. :^)
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibCore/CProcessStatisticsReader.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/Libraries/LibCore/CProcessStatisticsReader.cpp b/Libraries/LibCore/CProcessStatisticsReader.cpp
index cfd8f0b40c..316a5e5a09 100644
--- a/Libraries/LibCore/CProcessStatisticsReader.cpp
+++ b/Libraries/LibCore/CProcessStatisticsReader.cpp
@@ -44,7 +44,8 @@ HashMap<pid_t, CProcessStatistics> CProcessStatisticsReader::get_all()
process.amount_purgeable_nonvolatile = process_object.get("amount_purgeable_nonvolatile").to_u32();
process.icon_id = process_object.get("icon_id").to_int();
- auto thread_array = process_object.get("threads").as_array();
+ auto& thread_array = process_object.get_ptr("threads")->as_array();
+ process.threads.ensure_capacity(thread_array.size());
thread_array.for_each([&](auto& value) {
auto& thread_object = value.as_object();
CThreadStatistics thread;