1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 07:55:07 +00:00

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

View file

@ -62,7 +62,8 @@ void MemoryStatsWidget::refresh()
auto line = m_proc_memstat.read_line(BUFSIZ); auto line = m_proc_memstat.read_line(BUFSIZ);
if (line.is_null()) if (line.is_null())
break; 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) if (parts.size() < 9)
break; break;
bool ok; 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_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_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)); m_kmalloc_count_label->set_text(String::format("%u/%u (+%u)", kmalloc_call_count, kfree_call_count, kmalloc_call_count - kfree_call_count));
break;
} }
} }