mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:07:45 +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:
parent
e5f09ea170
commit
3f3f45580a
762 changed files with 8315 additions and 8316 deletions
|
@ -29,9 +29,9 @@ String FetchCommand::DataItem::Section::serialize() const
|
|||
case SectionType::HeaderFields:
|
||||
case SectionType::HeaderFieldsNot: {
|
||||
if (type == SectionType::HeaderFields)
|
||||
headers_builder.append("HEADER.FIELDS (");
|
||||
headers_builder.append("HEADER.FIELDS ("sv);
|
||||
else
|
||||
headers_builder.append("HEADERS.FIELDS.NOT (");
|
||||
headers_builder.append("HEADERS.FIELDS.NOT ("sv);
|
||||
|
||||
bool first = true;
|
||||
for (auto& field : headers.value()) {
|
||||
|
@ -55,7 +55,7 @@ String FetchCommand::DataItem::Section::serialize() const
|
|||
first = false;
|
||||
}
|
||||
if (ends_with_mime) {
|
||||
sb.append(".MIME");
|
||||
sb.append(".MIME"sv);
|
||||
}
|
||||
return sb.build();
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ String serialize_astring(StringView string)
|
|||
// Try to quote
|
||||
auto can_be_quoted = !(string.contains('\n') || string.contains('\r'));
|
||||
if (can_be_quoted) {
|
||||
auto escaped_str = string.replace("\\", "\\\\", ReplaceMode::All).replace("\"", "\\\"", ReplaceMode::All);
|
||||
auto escaped_str = string.replace("\\"sv, "\\\\"sv, ReplaceMode::All).replace("\""sv, "\\\""sv, ReplaceMode::All);
|
||||
return String::formatted("\"{}\"", escaped_str);
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ String SearchKey::serialize() const
|
|||
[&](New const&) { return String("NEW"); },
|
||||
[&](Not const& x) { return String::formatted("NOT {}", x.operand->serialize()); },
|
||||
[&](Old const&) { return String("OLD"); },
|
||||
[&](On const& x) { return String::formatted("ON {}", x.date.to_string("%d-%b-%Y")); },
|
||||
[&](On const& x) { return String::formatted("ON {}", x.date.to_string("%d-%b-%Y"sv)); },
|
||||
[&](Or const& x) { return String::formatted("OR {} {}", x.lhs->serialize(), x.rhs->serialize()); },
|
||||
[&](Recent const&) { return String("RECENT"); },
|
||||
[&](SearchKeys const& x) {
|
||||
|
@ -160,18 +160,18 @@ String SearchKey::serialize() const
|
|||
bool first = true;
|
||||
for (const auto& item : x.keys) {
|
||||
if (!first)
|
||||
sb.append(", ");
|
||||
sb.append(", "sv);
|
||||
sb.append(item->serialize());
|
||||
first = false;
|
||||
}
|
||||
return sb.build();
|
||||
},
|
||||
[&](Seen const&) { return String("SEEN"); },
|
||||
[&](SentBefore const& x) { return String::formatted("SENTBEFORE {}", x.date.to_string("%d-%b-%Y")); },
|
||||
[&](SentOn const& x) { return String::formatted("SENTON {}", x.date.to_string("%d-%b-%Y")); },
|
||||
[&](SentSince const& x) { return String::formatted("SENTSINCE {}", x.date.to_string("%d-%b-%Y")); },
|
||||
[&](SentBefore const& x) { return String::formatted("SENTBEFORE {}", x.date.to_string("%d-%b-%Y"sv)); },
|
||||
[&](SentOn const& x) { return String::formatted("SENTON {}", x.date.to_string("%d-%b-%Y"sv)); },
|
||||
[&](SentSince const& x) { return String::formatted("SENTSINCE {}", x.date.to_string("%d-%b-%Y"sv)); },
|
||||
[&](SequenceSet const& x) { return x.sequence.serialize(); },
|
||||
[&](Since const& x) { return String::formatted("SINCE {}", x.date.to_string("%d-%b-%Y")); },
|
||||
[&](Since const& x) { return String::formatted("SINCE {}", x.date.to_string("%d-%b-%Y"sv)); },
|
||||
[&](Smaller const& x) { return String::formatted("SMALLER {}", x.number); },
|
||||
[&](Subject const& x) { return String::formatted("SUBJECT {}", serialize_astring(x.subject)); },
|
||||
[&](Text const& x) { return String::formatted("TEXT {}", serialize_astring(x.text)); },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue