mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK+Userland: Remove some needlessly explicit conversions to StringView
This commit is contained in:
parent
c23060e21b
commit
b5f22b6e90
Notes:
sideshowbarker
2024-07-17 06:39:26 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/b5f22b6e90 Pull-request: https://github.com/SerenityOS/serenity/pull/23830 Reviewed-by: https://github.com/shannonbooth ✅
7 changed files with 18 additions and 18 deletions
10
AK/UUID.cpp
10
AK/UUID.cpp
|
@ -101,15 +101,15 @@ ErrorOr<String> UUID::to_string() const
|
|||
{
|
||||
auto buffer_span = m_uuid_buffer.span();
|
||||
StringBuilder builder(36);
|
||||
TRY(builder.try_append(encode_hex(buffer_span.trim(4)).view()));
|
||||
TRY(builder.try_append(encode_hex(buffer_span.trim(4))));
|
||||
TRY(builder.try_append('-'));
|
||||
TRY(builder.try_append(encode_hex(buffer_span.slice(4, 2)).view()));
|
||||
TRY(builder.try_append(encode_hex(buffer_span.slice(4, 2))));
|
||||
TRY(builder.try_append('-'));
|
||||
TRY(builder.try_append(encode_hex(buffer_span.slice(6, 2)).view()));
|
||||
TRY(builder.try_append(encode_hex(buffer_span.slice(6, 2))));
|
||||
TRY(builder.try_append('-'));
|
||||
TRY(builder.try_append(encode_hex(buffer_span.slice(8, 2)).view()));
|
||||
TRY(builder.try_append(encode_hex(buffer_span.slice(8, 2))));
|
||||
TRY(builder.try_append('-'));
|
||||
TRY(builder.try_append(encode_hex(buffer_span.slice(10, 6)).view()));
|
||||
TRY(builder.try_append(encode_hex(buffer_span.slice(10, 6))));
|
||||
return builder.to_string();
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -261,12 +261,12 @@ static ErrorOr<void> generate_loader_for_object(GUI::GML::Object const& gml_obje
|
|||
generator.set("class_name", gml_object.name());
|
||||
|
||||
auto append = [&]<size_t N>(auto& generator, char const(&text)[N]) -> ErrorOr<void> {
|
||||
generator.append(TRY(String::repeated(' ', indentation * 4)).bytes_as_string_view());
|
||||
generator.append(TRY(String::repeated(' ', indentation * 4)));
|
||||
generator.appendln(text);
|
||||
return {};
|
||||
};
|
||||
|
||||
generator.append(TRY(String::repeated(' ', (indentation - 1) * 4)).bytes_as_string_view());
|
||||
generator.append(TRY(String::repeated(' ', (indentation - 1) * 4)));
|
||||
generator.appendln("{");
|
||||
if (use_object_constructor == UseObjectConstructor::Yes)
|
||||
TRY(append(generator, "@object_name@ = TRY(@class_name@::try_create());"));
|
||||
|
@ -336,7 +336,7 @@ static ErrorOr<void> generate_loader_for_object(GUI::GML::Object const& gml_obje
|
|||
|
||||
TRY(append(generator, "TRY(::GUI::initialize(*@object_name@));"));
|
||||
|
||||
generator.append(TRY(String::repeated(' ', (indentation - 1) * 4)).bytes_as_string_view());
|
||||
generator.append(TRY(String::repeated(' ', (indentation - 1) * 4)));
|
||||
generator.appendln("}");
|
||||
|
||||
return {};
|
||||
|
@ -365,7 +365,7 @@ static ErrorOr<String> generate_cpp(NonnullRefPtr<GUI::GML::GMLFile> gml, Lexica
|
|||
};
|
||||
TRY(necessary_includes.try_set_from(always_necessary_includes));
|
||||
for (auto const& include : necessary_includes)
|
||||
generator.appendln(TRY(String::formatted("#include {}", include)).bytes_as_string_view());
|
||||
generator.appendln(TRY(String::formatted("#include {}", include)));
|
||||
|
||||
// FIXME: Use a UTF-8 aware function once possible.
|
||||
generator.set("main_class_name", main_class.name());
|
||||
|
|
|
@ -237,7 +237,7 @@ void MapWidget::context_menu_event(GUI::ContextMenuEvent& event)
|
|||
m_context_menu = GUI::Menu::construct();
|
||||
m_context_menu->add_action(GUI::Action::create(
|
||||
"&Copy Coordinates to Clipboard", MUST(Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-copy.png"sv)), [this](auto&) {
|
||||
GUI::Clipboard::the().set_plain_text(MUST(String::formatted("{}, {}", m_context_menu_latlng.latitude, m_context_menu_latlng.longitude)).bytes_as_string_view());
|
||||
GUI::Clipboard::the().set_plain_text(MUST(String::formatted("{}, {}", m_context_menu_latlng.latitude, m_context_menu_latlng.longitude)));
|
||||
}));
|
||||
m_context_menu->add_separator();
|
||||
if (!m_context_menu_actions.is_empty()) {
|
||||
|
|
|
@ -426,7 +426,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
|
|||
auto const filesystem_event_type = perf_event.get("fs_event_type"sv).value_or("").as_string();
|
||||
if (filesystem_event_type == "open"sv) {
|
||||
auto const string_index = perf_event.get_addr("filename_index"sv).value_or(0);
|
||||
auto const filename = profile_strings.get(string_index).value_or("").view();
|
||||
auto const filename = profile_strings.get(string_index).value_or("");
|
||||
fsdata.data = Event::OpenEventData {
|
||||
.dirfd = perf_event.get_integer<int>("dirfd"sv).value_or(0),
|
||||
.path = filename,
|
||||
|
@ -435,28 +435,28 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
|
|||
};
|
||||
} else if (filesystem_event_type == "close"sv) {
|
||||
auto const string_index = perf_event.get_addr("filename_index"sv).value_or(0);
|
||||
auto const filename = profile_strings.get(string_index).value_or("").view();
|
||||
auto const filename = profile_strings.get(string_index).value_or("");
|
||||
fsdata.data = Event::CloseEventData {
|
||||
.fd = perf_event.get_integer<int>("fd"sv).value_or(0),
|
||||
.path = filename,
|
||||
};
|
||||
} else if (filesystem_event_type == "readv"sv) {
|
||||
auto const string_index = perf_event.get_addr("filename_index"sv).value_or(0);
|
||||
auto const filename = profile_strings.get(string_index).value().view();
|
||||
auto const filename = profile_strings.get(string_index).value();
|
||||
fsdata.data = Event::ReadvEventData {
|
||||
.fd = perf_event.get_integer<int>("fd"sv).value_or(0),
|
||||
.path = filename,
|
||||
};
|
||||
} else if (filesystem_event_type == "read"sv) {
|
||||
auto const string_index = perf_event.get_addr("filename_index"sv).value_or(0);
|
||||
auto const filename = profile_strings.get(string_index).value().view();
|
||||
auto const filename = profile_strings.get(string_index).value();
|
||||
fsdata.data = Event::ReadEventData {
|
||||
.fd = perf_event.get_integer<int>("fd"sv).value_or(0),
|
||||
.path = filename,
|
||||
};
|
||||
} else if (filesystem_event_type == "pread"sv) {
|
||||
auto const string_index = perf_event.get_addr("filename_index"sv).value_or(0);
|
||||
auto const filename = profile_strings.get(string_index).value().view();
|
||||
auto const filename = profile_strings.get(string_index).value();
|
||||
fsdata.data = Event::PreadEventData {
|
||||
.fd = perf_event.get_integer<int>("fd"sv).value_or(0),
|
||||
.path = filename,
|
||||
|
|
|
@ -186,7 +186,7 @@ struct AK::Formatter<DSP::ProcessorRangeParameter> : AK::StandardFormatter {
|
|||
m_width = m_width.value_or(0);
|
||||
m_precision = m_precision.value_or(NumericLimits<size_t>::max());
|
||||
|
||||
TRY(builder.put_literal(TRY(String::formatted("[{} - {}]: {}", value.min_value(), value.max_value(), value.value())).bytes_as_string_view()));
|
||||
TRY(builder.put_literal(TRY(String::formatted("[{} - {}]: {}", value.min_value(), value.max_value(), value.value()))));
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
|
|
@ -172,7 +172,7 @@ ErrorOr<void> MarkupGenerator::error_to_html(Error const& error, StringBuilder&
|
|||
auto message_string = message.to_string_without_side_effects();
|
||||
auto uncaught_message = TRY(String::formatted("Uncaught {}[{}]: ", in_promise ? "(in promise) " : "", name_string));
|
||||
|
||||
TRY(html_output.try_append(TRY(wrap_string_in_style(uncaught_message, StyleType::Invalid)).bytes_as_string_view()));
|
||||
TRY(html_output.try_append(TRY(wrap_string_in_style(uncaught_message, StyleType::Invalid))));
|
||||
TRY(html_output.try_appendff("{}<br>", message_string.is_empty() ? "\"\"" : escape_html_entities(message_string)));
|
||||
|
||||
for (size_t i = 0; i < error.traceback().size() - min(error.traceback().size(), 3); i++) {
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Markdown {
|
|||
|
||||
ByteString Heading::render_to_html(bool) const
|
||||
{
|
||||
auto input = Unicode::normalize(m_text.render_for_raw_print().view(), Unicode::NormalizationForm::NFD);
|
||||
auto input = Unicode::normalize(m_text.render_for_raw_print(), Unicode::NormalizationForm::NFD);
|
||||
auto slugified = MUST(AK::slugify(input));
|
||||
return ByteString::formatted("<h{} id='{}'><a href='#{}'>#</a> {}</h{}>\n", m_level, slugified, slugified, m_text.render_to_html(), m_level);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue