1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 15:57:36 +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

@ -17,7 +17,7 @@ NonnullRefPtr<ClipboardHistoryModel> ClipboardHistoryModel::create()
}
ClipboardHistoryModel::ClipboardHistoryModel()
: m_history_limit(Config::read_i32("ClipboardHistory", "ClipboardHistory", "NumHistoryItems", 20))
: m_history_limit(Config::read_i32("ClipboardHistory"sv, "ClipboardHistory"sv, "NumHistoryItems"sv, 20))
{
}
@ -37,26 +37,26 @@ String ClipboardHistoryModel::column_name(int column) const
}
}
static char const* bpp_for_format_resilient(String format)
static StringView bpp_for_format_resilient(String format)
{
unsigned format_uint = format.to_uint().value_or(static_cast<unsigned>(Gfx::BitmapFormat::Invalid));
// Cannot use Gfx::Bitmap::bpp_for_format here, as we have to accept invalid enum values.
switch (static_cast<Gfx::BitmapFormat>(format_uint)) {
case Gfx::BitmapFormat::Indexed1:
return "1";
return "1"sv;
case Gfx::BitmapFormat::Indexed2:
return "2";
return "2"sv;
case Gfx::BitmapFormat::Indexed4:
return "4";
return "4"sv;
case Gfx::BitmapFormat::Indexed8:
return "8";
return "8"sv;
case Gfx::BitmapFormat::BGRx8888:
case Gfx::BitmapFormat::BGRA8888:
return "32";
return "32"sv;
case Gfx::BitmapFormat::Invalid:
/* fall-through */
default:
return "?";
return "?"sv;
}
}
@ -69,7 +69,7 @@ GUI::Variant ClipboardHistoryModel::data(const GUI::ModelIndex& index, GUI::Mode
auto& time = item.time;
switch (index.column()) {
case Column::Data:
if (data_and_type.mime_type.starts_with("text/"))
if (data_and_type.mime_type.starts_with("text/"sv))
return String::copy(data_and_type.data);
if (data_and_type.mime_type == "image/x-serenityos") {
StringBuilder builder;
@ -79,11 +79,11 @@ GUI::Variant ClipboardHistoryModel::data(const GUI::ModelIndex& index, GUI::Mode
builder.append(data_and_type.metadata.get("height").value_or("?"));
builder.append('x');
builder.append(bpp_for_format_resilient(data_and_type.metadata.get("format").value_or("0")));
builder.append(" bitmap");
builder.append("]");
builder.append(" bitmap"sv);
return builder.to_string();
}
if (data_and_type.mime_type.starts_with("glyph/")) {
if (data_and_type.mime_type.starts_with("glyph/"sv)) {
StringBuilder builder;
auto count = data_and_type.metadata.get("count").value().to_uint().value_or(0);
auto start = data_and_type.metadata.get("start").value().to_uint().value_or(0);

View file

@ -26,7 +26,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::pledge("stdio recvfd sendfd rpath"));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
auto app_icon = TRY(GUI::Icon::try_create_default_icon("edit-copy"));
auto app_icon = TRY(GUI::Icon::try_create_default_icon("edit-copy"sv));
auto main_window = TRY(GUI::Window::try_create());
main_window->set_title("Clipboard history");
@ -67,7 +67,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
applet_window->set_has_alpha_channel(true);
auto icon_widget = TRY(applet_window->try_set_main_widget<GUI::ImageWidget>());
icon_widget->set_tooltip("Clipboard History");
icon_widget->load_from_file("/res/icons/16x16/edit-copy.png");
icon_widget->load_from_file("/res/icons/16x16/edit-copy.png"sv);
icon_widget->on_click = [&main_window = *main_window] {
main_window.show();
main_window.move_to_front();