mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:07:45 +00:00
Everywhere: Add deprecated_ prefix to JsonValue::to_byte_string
`JsonValue::to_byte_string` has peculiar type-erasure semantics which is not usually intended. Unfortunately, it also has a very stereotypical name which does not warn about unexpected behavior. So let's prefix it with `deprecated_` to make new code use `as_string` if it just wants to get string value or `serialized<StringBuilder>` if it needs to do proper serialization.
This commit is contained in:
parent
4ed5287792
commit
ccd701809f
20 changed files with 46 additions and 50 deletions
|
@ -108,11 +108,7 @@ void print(JsonValue const& value, int spaces_per_indent, int indent, bool use_c
|
|||
else if (value.is_null())
|
||||
out("\033[34;1m");
|
||||
}
|
||||
if (value.is_string())
|
||||
out("\"");
|
||||
out("{}", value.to_byte_string());
|
||||
if (value.is_string())
|
||||
out("\"");
|
||||
out("{}", value);
|
||||
if (use_color)
|
||||
out("\033[0m");
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
out("{:>4}: ", interrupt);
|
||||
|
||||
for (size_t i = 0; i < cpu_count; ++i)
|
||||
out("{:>10}", call_counts[i].to_byte_string());
|
||||
out("{:>10}", call_counts[i].as_integer<u64>());
|
||||
|
||||
outln(" {:10} {:30}", controller, purpose);
|
||||
});
|
||||
|
|
|
@ -49,7 +49,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
for (auto& value : sorted_regions) {
|
||||
auto& map = value.as_object();
|
||||
auto address = map.get_addr("address"sv).value_or(0);
|
||||
auto size = map.get("size"sv).value_or({}).to_byte_string();
|
||||
auto size = map.get_u64("size"sv).value();
|
||||
|
||||
auto access = ByteString::formatted("{}{}{}{}{}",
|
||||
(map.get_bool("readable"sv).value_or(false) ? "r" : "-"),
|
||||
|
@ -61,13 +61,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
out("{:p} ", address);
|
||||
out("{:>10} ", size);
|
||||
if (extended) {
|
||||
auto resident = map.get("amount_resident"sv).value_or({}).to_byte_string();
|
||||
auto dirty = map.get("amount_dirty"sv).value_or({}).to_byte_string();
|
||||
auto vmobject = map.get_byte_string("vmobject"sv).value_or({});
|
||||
auto resident = map.get_u64("amount_resident"sv).value();
|
||||
auto dirty = map.get_u64("amount_dirty"sv).value();
|
||||
auto vmobject = map.get_byte_string("vmobject"sv).value();
|
||||
if (vmobject.ends_with("VMObject"sv))
|
||||
vmobject = vmobject.substring(0, vmobject.length() - 8);
|
||||
auto purgeable = map.get("purgeable"sv).value_or({}).to_byte_string();
|
||||
auto cow_pages = map.get("cow_pages"sv).value_or({}).to_byte_string();
|
||||
auto purgeable = map.get_u64("purgeable"sv).value();
|
||||
auto cow_pages = map.get_u64("cow_pages"sv).value();
|
||||
out("{:>10} ", resident);
|
||||
out("{:>10} ", dirty);
|
||||
out("{:6} ", access);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue