1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:47:34 +00:00

Everywhere: Add sv suffix to strings relying on StringView(char const*)

Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
This commit is contained in:
sin-ack 2022-07-11 17:32:29 +00:00 committed by Andreas Kling
parent e5f09ea170
commit 3f3f45580a
762 changed files with 8315 additions and 8316 deletions

View file

@ -37,7 +37,7 @@ DownloadWidget::DownloadWidget(const URL& url)
m_destination_path = builder.to_string();
}
auto close_on_finish = Config::read_bool("Browser", "Preferences", "CloseDownloadWidgetOnFinish", false);
auto close_on_finish = Config::read_bool("Browser"sv, "Preferences"sv, "CloseDownloadWidgetOnFinish"sv, false);
m_elapsed_timer.start();
m_download = Web::ResourceLoader::the().connector().start_request("GET", url);
@ -49,7 +49,7 @@ DownloadWidget::DownloadWidget(const URL& url)
{
auto file_or_error = Core::Stream::File::open(m_destination_path, Core::Stream::OpenMode::Write);
if (file_or_error.is_error()) {
GUI::MessageBox::show(window(), String::formatted("Cannot open {} for writing", m_destination_path), "Download failed", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), String::formatted("Cannot open {} for writing", m_destination_path), "Download failed"sv, GUI::MessageBox::Type::Error);
window()->close();
return;
}
@ -68,7 +68,7 @@ DownloadWidget::DownloadWidget(const URL& url)
auto& animation_layout = animation_container.set_layout<GUI::HorizontalBoxLayout>();
m_browser_image = animation_container.add<GUI::ImageWidget>();
m_browser_image->load_from_file("/res/graphics/download-animation.gif");
m_browser_image->load_from_file("/res/graphics/download-animation.gif"sv);
animation_layout.add_spacer();
auto& source_label = add<GUI::Label>(String::formatted("From: {}", url));
@ -90,7 +90,7 @@ DownloadWidget::DownloadWidget(const URL& url)
m_close_on_finish_checkbox->set_checked(close_on_finish);
m_close_on_finish_checkbox->on_checked = [&](bool checked) {
Config::write_bool("Browser", "Preferences", "CloseDownloadWidgetOnFinish", checked);
Config::write_bool("Browser"sv, "Preferences"sv, "CloseDownloadWidgetOnFinish"sv, checked);
};
auto& button_container = add<GUI::Widget>();
@ -126,7 +126,7 @@ void DownloadWidget::did_progress(Optional<u32> total_size, u32 downloaded_size)
{
StringBuilder builder;
builder.append("Downloaded ");
builder.append("Downloaded "sv);
builder.append(human_readable_size(downloaded_size));
builder.appendff(" in {} sec", m_elapsed_timer.elapsed() / 1000);
m_progress_label->set_text(builder.to_string());
@ -140,7 +140,7 @@ void DownloadWidget::did_progress(Optional<u32> total_size, u32 downloaded_size)
} else {
builder.append(human_readable_size(downloaded_size));
}
builder.append(" of ");
builder.append(" of "sv);
builder.append(m_url.basename());
window()->set_title(builder.to_string());
}
@ -150,7 +150,7 @@ void DownloadWidget::did_finish(bool success)
{
dbgln("did_finish, success={}", success);
m_browser_image->load_from_file("/res/graphics/download-finished.gif");
m_browser_image->load_from_file("/res/graphics/download-finished.gif"sv);
window()->set_title("Download finished!");
m_close_button->set_enabled(true);
m_cancel_button->set_text("Open in Folder");
@ -161,7 +161,7 @@ void DownloadWidget::did_finish(bool success)
m_cancel_button->update();
if (!success) {
GUI::MessageBox::show(window(), String::formatted("Download failed for some reason"), "Download failed", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), String::formatted("Download failed for some reason"), "Download failed"sv, GUI::MessageBox::Type::Error);
window()->close();
return;
}