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.
This commit is contained in:
Timothy Flynn 2022-01-28 09:30:02 -05:00 committed by Linus Groh
parent 54d89401df
commit bd5662d6f2
Notes: sideshowbarker 2024-07-17 20:19:08 +09:00
3 changed files with 5 additions and 5 deletions

View file

@ -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) });
});
}

View file

@ -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));
}
}
}

View file

@ -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(" - ");