From a4337279611ad23e0b88b36dacba198bfc10a99b Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 6 Jan 2022 18:01:12 +0100 Subject: [PATCH] LibGUI: Avoid double hash lookup in ModelSelection::add() --- Userland/Libraries/LibGUI/ModelSelection.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibGUI/ModelSelection.cpp b/Userland/Libraries/LibGUI/ModelSelection.cpp index 1aa22a3d64..825384c280 100644 --- a/Userland/Libraries/LibGUI/ModelSelection.cpp +++ b/Userland/Libraries/LibGUI/ModelSelection.cpp @@ -29,10 +29,8 @@ void ModelSelection::set(const ModelIndex& index) void ModelSelection::add(const ModelIndex& index) { VERIFY(index.is_valid()); - if (m_indices.contains(index)) - return; - m_indices.set(index); - notify_selection_changed(); + if (m_indices.set(index) == AK::HashSetResult::InsertedNewEntry) + notify_selection_changed(); } void ModelSelection::add_all(const Vector& indices)