From f53aa959dfa2de0076d4e20a4bcc88e9563d53d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Sun, 2 Jul 2023 13:26:34 +0200 Subject: [PATCH] LibManual: Compare nodes by path This makes them suited for hash map usage. --- Userland/Libraries/LibManual/Node.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Userland/Libraries/LibManual/Node.h b/Userland/Libraries/LibManual/Node.h index fd45fe8302..c96fafbddf 100644 --- a/Userland/Libraries/LibManual/Node.h +++ b/Userland/Libraries/LibManual/Node.h @@ -38,6 +38,24 @@ public: // Finds a page via the help://man///page URLs. // This will automatically start discovering pages by inspecting the filesystem. static ErrorOr> try_find_from_help_url(URL const&); + + bool operator==(Node const& other) const + { + if (auto this_path = this->path(), other_path = other.path(); + !this_path.is_error() && !other_path.is_error()) { + return this_path.release_value() == other_path.release_value(); + } + return false; + } +}; + +} + +namespace AK { + +template +requires(IsBaseOf) struct Traits : public GenericTraits { + static unsigned hash(T p) { return Traits::hash(p.path()); } }; }