From bd5662d6f23395a8a91ecff026c04d9a0e8ea41f Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Fri, 28 Jan 2022 09:30:02 -0500 Subject: [PATCH] CharacterMap: Move display name strings into the search results object Now that we're passing the display name directly to the search results structure, let's move() the string instead of copying it. --- Userland/Applications/CharacterMap/CharacterSearchWidget.cpp | 4 ++-- Userland/Applications/CharacterMap/SearchCharacters.h | 4 ++-- Userland/Applications/CharacterMap/main.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Userland/Applications/CharacterMap/CharacterSearchWidget.cpp b/Userland/Applications/CharacterMap/CharacterSearchWidget.cpp index 49f0ee13e7b..db25ccc45ff 100644 --- a/Userland/Applications/CharacterMap/CharacterSearchWidget.cpp +++ b/Userland/Applications/CharacterMap/CharacterSearchWidget.cpp @@ -85,10 +85,10 @@ void CharacterSearchWidget::search() auto query = m_search_input->text(); if (query.is_empty()) return; - for_each_character_containing(query, [&](auto code_point, auto& display_name) { + for_each_character_containing(query, [&](auto code_point, auto display_name) { StringBuilder builder; builder.append_code_point(code_point); - model.add_result({ code_point, builder.build(), display_name }); + model.add_result({ code_point, builder.build(), move(display_name) }); }); } diff --git a/Userland/Applications/CharacterMap/SearchCharacters.h b/Userland/Applications/CharacterMap/SearchCharacters.h index ef5e76ee5ce..a4350bd0cd1 100644 --- a/Userland/Applications/CharacterMap/SearchCharacters.h +++ b/Userland/Applications/CharacterMap/SearchCharacters.h @@ -18,9 +18,9 @@ void for_each_character_containing(StringView query, Callback callback) // FIXME: There's probably a better way to do this than just looping, but it still only takes ~150ms to run for me! for (u32 code_point = 1; code_point <= maximum_code_point; ++code_point) { if (auto maybe_display_name = Unicode::code_point_display_name(code_point); maybe_display_name.has_value()) { - auto& display_name = maybe_display_name.value(); + auto display_name = maybe_display_name.release_value(); if (display_name.contains(uppercase_query_view, AK::CaseSensitivity::CaseSensitive)) - callback(code_point, display_name); + callback(code_point, move(display_name)); } } } diff --git a/Userland/Applications/CharacterMap/main.cpp b/Userland/Applications/CharacterMap/main.cpp index 62ae2727d96..d1a840394ba 100644 --- a/Userland/Applications/CharacterMap/main.cpp +++ b/Userland/Applications/CharacterMap/main.cpp @@ -21,7 +21,7 @@ static void search_and_print_results(String const& query) { outln("Searching for '{}'", query); u32 result_count = 0; - for_each_character_containing(query, [&](auto code_point, auto& display_name) { + for_each_character_containing(query, [&](auto code_point, auto display_name) { StringBuilder builder; builder.append_code_point(code_point); builder.append(" - ");