mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-29 06:02:07 +03:00
pmap: Sort memory regions in output
This makes the program 100% nicer to use. :^)
This commit is contained in:
parent
7a71d4b887
commit
f8d643284e
Notes:
sideshowbarker
2024-07-18 22:54:10 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/f8d643284e2
@ -26,6 +26,7 @@
|
||||
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/JsonObject.h>
|
||||
#include <AK/QuickSort.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
@ -70,7 +71,13 @@ int main(int argc, char** argv)
|
||||
auto file_contents = file->read_all();
|
||||
auto json = JsonValue::from_string(file_contents);
|
||||
ASSERT(json.has_value());
|
||||
json.value().as_array().for_each([](auto& value) {
|
||||
|
||||
Vector<JsonValue> sorted_regions = json.value().as_array().values();
|
||||
quick_sort(sorted_regions, [](auto& a, auto& b) {
|
||||
return a.as_object().get("address").to_u32() < b.as_object().get("address").to_u32();
|
||||
});
|
||||
|
||||
for (auto& value : sorted_regions) {
|
||||
auto map = value.as_object();
|
||||
auto address = map.get("address").to_int();
|
||||
auto size = map.get("size").to_string();
|
||||
@ -100,7 +107,7 @@ int main(int argc, char** argv)
|
||||
auto name = map.get("name").to_string();
|
||||
printf("%-20s ", name.characters());
|
||||
printf("\n");
|
||||
});
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user