mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 08:57:47 +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
|
@ -116,7 +116,7 @@ int OptionParser::getopt()
|
|||
m_consumed_args = 0;
|
||||
} else {
|
||||
// Alright, so we have an option on our hands!
|
||||
bool is_long_option = arg.starts_with("--");
|
||||
bool is_long_option = arg.starts_with("--"sv);
|
||||
if (is_long_option)
|
||||
res = handle_long_option();
|
||||
else
|
||||
|
@ -146,7 +146,7 @@ bool OptionParser::lookup_short_option(char option, int& needs_value) const
|
|||
return false;
|
||||
}
|
||||
|
||||
if (parts[1].starts_with("::")) {
|
||||
if (parts[1].starts_with("::"sv)) {
|
||||
// If an option is followed by two colons, it optionally accepts an
|
||||
// argument.
|
||||
needs_value = optional_argument;
|
||||
|
|
|
@ -451,7 +451,7 @@ void endservent()
|
|||
static bool fill_getserv_buffers(char const* line, ssize_t read)
|
||||
{
|
||||
// Splitting the line by tab delimiter and filling the servent buffers name, port, and protocol members.
|
||||
auto split_line = StringView(line, read).replace(" ", "\t", ReplaceMode::All).split('\t');
|
||||
auto split_line = StringView(line, read).replace(" "sv, "\t"sv, ReplaceMode::All).split('\t');
|
||||
|
||||
// This indicates an incorrect file format.
|
||||
// Services file entries should always at least contain
|
||||
|
@ -474,7 +474,7 @@ static bool fill_getserv_buffers(char const* line, ssize_t read)
|
|||
__getserv_port_buffer = number.value();
|
||||
|
||||
// Remove any annoying whitespace at the end of the protocol.
|
||||
__getserv_protocol_buffer = port_protocol_split[1].replace(" ", "", ReplaceMode::All).replace("\t", "", ReplaceMode::All).replace("\n", "", ReplaceMode::All);
|
||||
__getserv_protocol_buffer = port_protocol_split[1].replace(" "sv, ""sv, ReplaceMode::All).replace("\t"sv, ""sv, ReplaceMode::All).replace("\n"sv, ""sv, ReplaceMode::All);
|
||||
__getserv_alias_list_buffer.clear();
|
||||
|
||||
// If there are aliases for the service, we will fill the alias list buffer.
|
||||
|
@ -630,7 +630,7 @@ void endprotoent()
|
|||
static bool fill_getproto_buffers(char const* line, ssize_t read)
|
||||
{
|
||||
String string_line = String(line, read);
|
||||
auto split_line = string_line.replace(" ", "\t", ReplaceMode::All).split('\t');
|
||||
auto split_line = string_line.replace(" "sv, "\t"sv, ReplaceMode::All).split('\t');
|
||||
|
||||
// This indicates an incorrect file format. Protocols file entries should
|
||||
// always have at least a name and a protocol.
|
||||
|
|
|
@ -297,7 +297,7 @@ struct ReadElement {
|
|||
template<>
|
||||
struct ReadElement<char*, ReadKind::Normal> {
|
||||
ReadElement(StringView scan_set = {}, bool invert = false)
|
||||
: scan_set(scan_set.is_null() ? " \t\n\f\r" : scan_set)
|
||||
: scan_set(scan_set.is_null() ? " \t\n\f\r"sv : scan_set)
|
||||
, invert(scan_set.is_null() ? true : invert)
|
||||
, was_null(scan_set.is_null())
|
||||
{
|
||||
|
|
|
@ -87,7 +87,7 @@ static bool parse_shadow_entry(String const& line)
|
|||
}
|
||||
|
||||
if (min_string.is_empty())
|
||||
min_string = "-1";
|
||||
min_string = "-1"sv;
|
||||
auto min_value = min_string.to_int();
|
||||
if (!min_value.has_value()) {
|
||||
dbgln("getspent(): Malformed min value on line {}", s_line_number);
|
||||
|
@ -95,7 +95,7 @@ static bool parse_shadow_entry(String const& line)
|
|||
}
|
||||
|
||||
if (max_string.is_empty())
|
||||
max_string = "-1";
|
||||
max_string = "-1"sv;
|
||||
auto max_value = max_string.to_int();
|
||||
if (!max_value.has_value()) {
|
||||
dbgln("getspent(): Malformed max value on line {}", s_line_number);
|
||||
|
@ -103,7 +103,7 @@ static bool parse_shadow_entry(String const& line)
|
|||
}
|
||||
|
||||
if (warn_string.is_empty())
|
||||
warn_string = "-1";
|
||||
warn_string = "-1"sv;
|
||||
auto warn = warn_string.to_int();
|
||||
if (!warn.has_value()) {
|
||||
dbgln("getspent(): Malformed warn on line {}", s_line_number);
|
||||
|
@ -111,7 +111,7 @@ static bool parse_shadow_entry(String const& line)
|
|||
}
|
||||
|
||||
if (inact_string.is_empty())
|
||||
inact_string = "-1";
|
||||
inact_string = "-1"sv;
|
||||
auto inact = inact_string.to_int();
|
||||
if (!inact.has_value()) {
|
||||
dbgln("getspent(): Malformed inact on line {}", s_line_number);
|
||||
|
@ -119,7 +119,7 @@ static bool parse_shadow_entry(String const& line)
|
|||
}
|
||||
|
||||
if (expire_string.is_empty())
|
||||
expire_string = "-1";
|
||||
expire_string = "-1"sv;
|
||||
auto expire = expire_string.to_int();
|
||||
if (!expire.has_value()) {
|
||||
dbgln("getspent(): Malformed expire on line {}", s_line_number);
|
||||
|
@ -127,7 +127,7 @@ static bool parse_shadow_entry(String const& line)
|
|||
}
|
||||
|
||||
if (flag_string.is_empty())
|
||||
flag_string = "0";
|
||||
flag_string = "0"sv;
|
||||
auto flag = flag_string.to_int();
|
||||
if (!flag.has_value()) {
|
||||
dbgln("getspent(): Malformed flag on line {}", s_line_number);
|
||||
|
|
|
@ -283,7 +283,7 @@ size_t strftime(char* destination, size_t max_size, char const* format, const st
|
|||
builder.append('\n');
|
||||
break;
|
||||
case 'p':
|
||||
builder.append(tm->tm_hour < 12 ? "AM" : "PM");
|
||||
builder.append(tm->tm_hour < 12 ? "AM"sv : "PM"sv);
|
||||
break;
|
||||
case 'r': {
|
||||
int display_hour = tm->tm_hour % 12;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue