1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 19:17:35 +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);