1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:48:10 +00:00

ProcessManager+WindowServer: Do a little less malloc() in CPU monitor code.

This commit is contained in:
Andreas Kling 2019-04-18 03:36:33 +02:00
parent 36a6c10b09
commit e74b5bc054
2 changed files with 5 additions and 3 deletions

View file

@ -148,7 +148,8 @@ void ProcessModel::update()
auto line = file.read_line(1024); auto line = file.read_line(1024);
if (line.is_empty()) if (line.is_empty())
break; break;
auto parts = String((const char*)line.pointer(), line.size() - 1, Chomp).split(','); auto chomped = String((const char*)line.pointer(), line.size() - 1, Chomp);
auto parts = chomped.split_view(',');
if (parts.size() < 18) if (parts.size() < 18)
break; break;
bool ok; bool ok;

View file

@ -40,8 +40,9 @@ void WSCPUMonitor::get_cpu_usage(unsigned& busy, unsigned& idle)
auto line = m_proc_all.read_line(BUFSIZ); auto line = m_proc_all.read_line(BUFSIZ);
if (line.is_null()) if (line.is_null())
break; break;
auto parts = String::from_byte_buffer(line).split(','); auto chomped = String((const char*)line.pointer(), line.size() - 1, Chomp);
if (parts.size() < 17) auto parts = chomped.split_view(',');
if (parts.size() < 18)
break; break;
bool ok; bool ok;
pid_t pid = parts[0].to_uint(ok); pid_t pid = parts[0].to_uint(ok);