diff options
author | Andreas Kling <kling@serenityos.org> | 2021-05-23 11:08:32 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-23 11:10:15 +0200 |
commit | a1e133cc6bf8617d8299e4f1ae8df7b7d5289205 (patch) | |
tree | d473905c402aa6d82357ee82e8591aff4b20e39c /Userland/Utilities/lsof.cpp | |
parent | a345a1f4a155ae62fb218f7f4c13d08911a73397 (diff) | |
download | serenity-a1e133cc6bf8617d8299e4f1ae8df7b7d5289205.zip |
LibCore: Make ProcessStatisticsReader return results in a Vector
The HashMap API was overkill and made using this less ergonomic than
it should be.
Diffstat (limited to 'Userland/Utilities/lsof.cpp')
-rw-r--r-- | Userland/Utilities/lsof.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Userland/Utilities/lsof.cpp b/Userland/Utilities/lsof.cpp index 09481fc9fd..b639410f19 100644 --- a/Userland/Utilities/lsof.cpp +++ b/Userland/Utilities/lsof.cpp @@ -150,22 +150,22 @@ int main(int argc, char* argv[]) if (!processes.has_value()) return 1; if (arg_pid == -1) { - for (auto process : processes.value()) { - if (process.key == 0) + for (auto& process : processes.value()) { + if (process.pid == 0) continue; - auto open_files = get_open_files_by_pid(process.key); + auto open_files = get_open_files_by_pid(process.pid); if (open_files.is_empty()) continue; - for (auto file : open_files) { + for (auto& file : open_files) { if ((arg_all_processes) || (arg_fd != -1 && file.fd == arg_fd) - || (arg_uid_int != -1 && (int)process.value.uid == arg_uid_int) - || (arg_uid != nullptr && process.value.username == arg_uid) - || (arg_pgid != -1 && (int)process.value.pgid == arg_pgid) + || (arg_uid_int != -1 && (int)process.uid == arg_uid_int) + || (arg_uid != nullptr && process.username == arg_uid) + || (arg_pgid != -1 && (int)process.pgid == arg_pgid) || (arg_filename != nullptr && file.name == arg_filename)) - display_entry(file, process.value); + display_entry(file, process); } } } else { @@ -175,7 +175,7 @@ int main(int argc, char* argv[]) return 0; for (auto file : open_files) { - display_entry(file, processes.value().get(arg_pid).value()); + display_entry(file, *processes->find_if([&](auto& entry) { return entry.pid == arg_pid; })); } } |