mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
SystemMonitor: Use new format functions.
This commit is contained in:
parent
6ed3a4b5fe
commit
0dec600a2a
Notes:
sideshowbarker
2024-07-19 02:00:08 +09:00
Author: https://github.com/asynts Commit: https://github.com/SerenityOS/serenity/commit/0dec600a2a2 Pull-request: https://github.com/SerenityOS/serenity/pull/3704
7 changed files with 21 additions and 21 deletions
|
@ -119,12 +119,12 @@ void MemoryStatsWidget::refresh()
|
|||
size_t user_pages_available = user_physical_allocated + user_physical_available;
|
||||
size_t supervisor_pages_available = super_physical_alloc + super_physical_free;
|
||||
|
||||
m_kmalloc_space_label->set_text(String::format("%uK/%uK", bytes_to_kb(kmalloc_allocated), bytes_to_kb(kmalloc_sum_available)));
|
||||
m_user_physical_pages_label->set_text(String::format("%uK/%uK", page_count_to_kb(user_physical_allocated), page_count_to_kb(user_pages_available)));
|
||||
m_supervisor_physical_pages_label->set_text(String::format("%uK/%uK", page_count_to_kb(super_physical_alloc), page_count_to_kb(supervisor_pages_available)));
|
||||
m_kmalloc_count_label->set_text(String::format("%u", kmalloc_call_count));
|
||||
m_kfree_count_label->set_text(String::format("%u", kfree_call_count));
|
||||
m_kmalloc_difference_label->set_text(String::format("+%u", kmalloc_call_count - kfree_call_count));
|
||||
m_kmalloc_space_label->set_text(String::formatted("{}K/{}K", bytes_to_kb(kmalloc_allocated), bytes_to_kb(kmalloc_sum_available)));
|
||||
m_user_physical_pages_label->set_text(String::formatted("{}K/{}K", page_count_to_kb(user_physical_allocated), page_count_to_kb(user_pages_available)));
|
||||
m_supervisor_physical_pages_label->set_text(String::formatted("{}K/{}K", page_count_to_kb(super_physical_alloc), page_count_to_kb(supervisor_pages_available)));
|
||||
m_kmalloc_count_label->set_text(String::formatted("{}", kmalloc_call_count));
|
||||
m_kfree_count_label->set_text(String::formatted("{}", kfree_call_count));
|
||||
m_kmalloc_difference_label->set_text(String::formatted("{:+}", kmalloc_call_count - kfree_call_count));
|
||||
|
||||
m_graph.set_max(page_count_to_kb(user_pages_available));
|
||||
m_graph.add_value(page_count_to_kb(user_physical_allocated));
|
||||
|
|
|
@ -70,5 +70,5 @@ void ProcessFileDescriptorMapWidget::set_pid(pid_t pid)
|
|||
if (m_pid == pid)
|
||||
return;
|
||||
m_pid = pid;
|
||||
m_model->set_json_path(String::format("/proc/%d/fds", m_pid));
|
||||
m_model->set_json_path(String::formatted("/proc/{}/fds", m_pid));
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ ProcessMemoryMapWidget::ProcessMemoryMapWidget()
|
|||
Vector<GUI::JsonArrayModel::FieldSpec> pid_vm_fields;
|
||||
pid_vm_fields.empend(
|
||||
"Address", Gfx::TextAlignment::CenterLeft,
|
||||
[](auto& object) { return String::format("%#x", object.get("address").to_u32()); },
|
||||
[](auto& object) { return String::formatted("{:#x}", object.get("address").to_u32()); },
|
||||
[](auto& object) { return object.get("address").to_u32(); });
|
||||
pid_vm_fields.empend("size", "Size", Gfx::TextAlignment::CenterRight);
|
||||
pid_vm_fields.empend("amount_resident", "Resident", Gfx::TextAlignment::CenterRight);
|
||||
|
@ -133,7 +133,7 @@ void ProcessMemoryMapWidget::set_pid(pid_t pid)
|
|||
if (m_pid == pid)
|
||||
return;
|
||||
m_pid = pid;
|
||||
m_json_model->set_json_path(String::format("/proc/%d/vm", pid));
|
||||
m_json_model->set_json_path(String::formatted("/proc/{}/vm", pid));
|
||||
}
|
||||
|
||||
void ProcessMemoryMapWidget::refresh()
|
||||
|
|
|
@ -153,7 +153,7 @@ String ProcessModel::column_name(int column) const
|
|||
|
||||
static String pretty_byte_size(size_t size)
|
||||
{
|
||||
return String::format("%uK", size / 1024);
|
||||
return String::formatted("{}K", size / 1024);
|
||||
}
|
||||
|
||||
GUI::Variant ProcessModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const
|
||||
|
|
|
@ -53,5 +53,5 @@ void ProcessUnveiledPathsWidget::set_pid(pid_t pid)
|
|||
if (m_pid == pid)
|
||||
return;
|
||||
m_pid = pid;
|
||||
m_model->set_json_path(String::format("/proc/%d/unveil", m_pid));
|
||||
m_model->set_json_path(String::formatted("/proc/{}/unveil", m_pid));
|
||||
}
|
||||
|
|
|
@ -55,9 +55,9 @@ void ThreadStackWidget::set_ids(pid_t pid, pid_t tid)
|
|||
|
||||
void ThreadStackWidget::refresh()
|
||||
{
|
||||
auto file = Core::File::construct(String::format("/proc/%d/stacks/%d", m_pid, m_tid));
|
||||
auto file = Core::File::construct(String::formatted("/proc/{}/stacks/{}", m_pid, m_tid));
|
||||
if (!file->open(Core::IODevice::ReadOnly)) {
|
||||
m_stack_editor->set_text(String::format("Unable to open %s", file->filename().characters()));
|
||||
m_stack_editor->set_text(String::formatted("Unable to open {}", file->filename()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ private:
|
|||
|
||||
static bool can_access_pid(pid_t pid)
|
||||
{
|
||||
auto path = String::format("/proc/%d", pid);
|
||||
auto path = String::formatted("/proc/{}", pid);
|
||||
return access(path.characters(), X_OK) == 0;
|
||||
}
|
||||
|
||||
|
@ -469,21 +469,21 @@ NonnullRefPtr<GUI::Widget> build_pci_devices_tab()
|
|||
auto bus = object.get("bus").to_u32();
|
||||
auto slot = object.get("slot").to_u32();
|
||||
auto function = object.get("function").to_u32();
|
||||
return String::format("%04x:%02x:%02x.%d", seg, bus, slot, function);
|
||||
return String::formatted("{:04x}:{:02x}:{:02x}.{}", seg, bus, slot, function);
|
||||
});
|
||||
pci_fields.empend(
|
||||
"Class", Gfx::TextAlignment::CenterLeft,
|
||||
[db](const JsonObject& object) {
|
||||
auto class_id = object.get("class").to_u32();
|
||||
String class_name = db->get_class(class_id);
|
||||
return class_name == "" ? String::format("%04x", class_id) : class_name;
|
||||
return class_name == "" ? String::formatted("{:04x}", class_id) : class_name;
|
||||
});
|
||||
pci_fields.empend(
|
||||
"Vendor", Gfx::TextAlignment::CenterLeft,
|
||||
[db](const JsonObject& object) {
|
||||
auto vendor_id = object.get("vendor_id").to_u32();
|
||||
String vendor_name = db->get_vendor(vendor_id);
|
||||
return vendor_name == "" ? String::format("%02x", vendor_id) : vendor_name;
|
||||
return vendor_name == "" ? String::formatted("{:02x}", vendor_id) : vendor_name;
|
||||
});
|
||||
pci_fields.empend(
|
||||
"Device", Gfx::TextAlignment::CenterLeft,
|
||||
|
@ -491,13 +491,13 @@ NonnullRefPtr<GUI::Widget> build_pci_devices_tab()
|
|||
auto vendor_id = object.get("vendor_id").to_u32();
|
||||
auto device_id = object.get("device_id").to_u32();
|
||||
String device_name = db->get_device(vendor_id, device_id);
|
||||
return device_name == "" ? String::format("%02x", device_id) : device_name;
|
||||
return device_name == "" ? String::formatted("{:02x}", device_id) : device_name;
|
||||
});
|
||||
pci_fields.empend(
|
||||
"Revision", Gfx::TextAlignment::CenterRight,
|
||||
[](const JsonObject& object) {
|
||||
auto revision_id = object.get("revision_id").to_u32();
|
||||
return String::format("%02x", revision_id);
|
||||
return String::formatted("{:02x}", revision_id);
|
||||
});
|
||||
|
||||
pci_table_view.set_model(GUI::SortingProxyModel::create(GUI::JsonArrayModel::create("/proc/pci", move(pci_fields))));
|
||||
|
@ -545,7 +545,7 @@ NonnullRefPtr<GUI::Widget> build_graphs_tab()
|
|||
cpu_graph.set_text_color(Color::Green);
|
||||
cpu_graph.set_graph_color(Color::from_rgb(0x00bb00));
|
||||
cpu_graph.text_formatter = [](int value, int) {
|
||||
return String::format("%d%%", value);
|
||||
return String::formatted("{}%", value);
|
||||
};
|
||||
cpu_graphs.append(&cpu_graph);
|
||||
}
|
||||
|
@ -563,7 +563,7 @@ NonnullRefPtr<GUI::Widget> build_graphs_tab()
|
|||
memory_graph.set_text_color(Color::Cyan);
|
||||
memory_graph.set_graph_color(Color::from_rgb(0x00bbbb));
|
||||
memory_graph.text_formatter = [](int value, int max) {
|
||||
return String::format("%d / %d KiB", value, max);
|
||||
return String::formatted("{} / {} KiB", value, max);
|
||||
};
|
||||
|
||||
self.add<MemoryStatsWidget>(memory_graph);
|
||||
|
|
Loading…
Reference in a new issue