ProcessManager: Do a little less malloc() in the /proc/memstats parsing.

This commit is contained in:
Andreas Kling 2019-04-18 04:48:53 +02:00
parent ac19fabaaf
commit 67d7fc94fc
Notes: sideshowbarker 2024-07-19 14:40:06 +09:00

View file

@ -62,7 +62,8 @@ void MemoryStatsWidget::refresh()
auto line = m_proc_memstat.read_line(BUFSIZ);
if (line.is_null())
break;
auto parts = String::from_byte_buffer(line, Chomp).split(',');
auto chomped = String((const char*)line.pointer(), line.size() - 1, Chomp);
auto parts = chomped.split_view(',');
if (parts.size() < 9)
break;
bool ok;
@ -94,7 +95,6 @@ void MemoryStatsWidget::refresh()
m_user_physical_pages_label->set_text(String::format("%uK/%uK", page_count_to_kb(user_pages_alloc), page_count_to_kb(user_pages_available)));
m_supervisor_physical_pages_label->set_text(String::format("%uK/%uK", page_count_to_kb(supervisor_pages_alloc), page_count_to_kb(supervisor_pages_available)));
m_kmalloc_count_label->set_text(String::format("%u/%u (+%u)", kmalloc_call_count, kfree_call_count, kmalloc_call_count - kfree_call_count));
break;
}
}