Utilities/lscpu: Replace uses of JsonObject::get_deprecated()/get_ptr()

This commit is contained in:
Sam Atkins 2022-12-22 14:28:00 +00:00 committed by Tim Flynn
parent 8647743504
commit 7ce32cb82a
Notes: sideshowbarker 2024-07-17 00:53:02 +09:00

View File

@ -16,35 +16,35 @@
static void print_cache_info(StringView description, JsonObject const& cache_object)
{
outln("\t{}:", description);
outln("\t\tSize: {}", human_readable_size(cache_object.get_deprecated("size"sv).as_u32()));
outln("\t\tLine size: {}", human_readable_size(cache_object.get_deprecated("line_size"sv).as_u32()));
outln("\t\tSize: {}", human_readable_size(cache_object.get_u32("size"sv).value()));
outln("\t\tLine size: {}", human_readable_size(cache_object.get_u32("line_size"sv).value()));
};
static void print_cpu_info(JsonObject const& value)
{
outln("CPU {}:", value.get_deprecated("processor"sv).as_u32());
outln("\tVendor ID: {}", value.get_deprecated("vendor_id"sv).as_string());
outln("CPU {}:", value.get_u32("processor"sv).value());
outln("\tVendor ID: {}", value.get_deprecated_string("vendor_id"sv).value());
if (value.has("hypervisor_vendor_id"sv))
outln("\tHypervisor Vendor ID: {}", value.get_deprecated("hypervisor_vendor_id"sv).as_string());
outln("\tBrand: {}", value.get_deprecated("brand"sv).as_string());
outln("\tFamily: {}", value.get_deprecated("family"sv).as_u32());
outln("\tModel: {}", value.get_deprecated("model"sv).as_u32());
outln("\tStepping: {}", value.get_deprecated("stepping"sv).as_u32());
outln("\tType: {}", value.get_deprecated("type"sv).as_u32());
outln("\tHypervisor Vendor ID: {}", value.get_deprecated_string("hypervisor_vendor_id"sv).value());
outln("\tBrand: {}", value.get_deprecated_string("brand"sv).value());
outln("\tFamily: {}", value.get_u32("family"sv).value());
outln("\tModel: {}", value.get_u32("model"sv).value());
outln("\tStepping: {}", value.get_u32("stepping"sv).value());
outln("\tType: {}", value.get_u32("type"sv).value());
auto& caches = value.get_deprecated("caches"sv).as_object();
auto& caches = value.get_object("caches"sv).value();
if (caches.has("l1_data"sv))
print_cache_info("L1 data cache"sv, caches.get_deprecated("l1_data"sv).as_object());
print_cache_info("L1 data cache"sv, caches.get_object("l1_data"sv).value());
if (caches.has("l1_instruction"sv))
print_cache_info("L1 instruction cache"sv, caches.get_deprecated("l1_instruction"sv).as_object());
print_cache_info("L1 instruction cache"sv, caches.get_object("l1_instruction"sv).value());
if (caches.has("l2"sv))
print_cache_info("L2 cache"sv, caches.get_deprecated("l2"sv).as_object());
print_cache_info("L2 cache"sv, caches.get_object("l2"sv).value());
if (caches.has("l3"sv))
print_cache_info("L3 cache"sv, caches.get_deprecated("l3"sv).as_object());
print_cache_info("L3 cache"sv, caches.get_object("l3"sv).value());
out("\tFeatures: ");
auto& features = value.get_deprecated("features"sv).as_array();
auto& features = value.get_array("features"sv).value();
for (auto const& feature : features.values())
out("{} ", feature.as_string());