mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:47: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:
parent
e5f09ea170
commit
3f3f45580a
762 changed files with 8315 additions and 8316 deletions
16
AK/Format.h
16
AK/Format.h
|
@ -638,7 +638,7 @@ template<typename T, bool Supported = false>
|
|||
struct __FormatIfSupported : Formatter<StringView> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, FormatIfSupported<T> const&)
|
||||
{
|
||||
return Formatter<StringView>::format(builder, "?");
|
||||
return Formatter<StringView>::format(builder, "?"sv);
|
||||
}
|
||||
};
|
||||
template<typename T>
|
||||
|
@ -673,15 +673,15 @@ struct Formatter<Error> : Formatter<FormatString> {
|
|||
{
|
||||
#if defined(__serenity__) && defined(KERNEL)
|
||||
if (error.is_errno())
|
||||
return Formatter<FormatString>::format(builder, "Error(errno={})", error.code());
|
||||
return Formatter<FormatString>::format(builder, "Error({})", error.string_literal());
|
||||
return Formatter<FormatString>::format(builder, "Error(errno={})"sv, error.code());
|
||||
return Formatter<FormatString>::format(builder, "Error({})"sv, error.string_literal());
|
||||
#else
|
||||
if (error.is_syscall())
|
||||
return Formatter<FormatString>::format(builder, "{}: {} (errno={})", error.string_literal(), strerror(error.code()), error.code());
|
||||
return Formatter<FormatString>::format(builder, "{}: {} (errno={})"sv, error.string_literal(), strerror(error.code()), error.code());
|
||||
if (error.is_errno())
|
||||
return Formatter<FormatString>::format(builder, "{} (errno={})", strerror(error.code()), error.code());
|
||||
return Formatter<FormatString>::format(builder, "{} (errno={})"sv, strerror(error.code()), error.code());
|
||||
|
||||
return Formatter<FormatString>::format(builder, "{}", error.string_literal());
|
||||
return Formatter<FormatString>::format(builder, "{}"sv, error.string_literal());
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
@ -691,8 +691,8 @@ struct Formatter<ErrorOr<T, ErrorType>> : Formatter<FormatString> {
|
|||
ErrorOr<void> format(FormatBuilder& builder, ErrorOr<T, ErrorType> const& error_or)
|
||||
{
|
||||
if (error_or.is_error())
|
||||
return Formatter<FormatString>::format(builder, "{}", error_or.error());
|
||||
return Formatter<FormatString>::format(builder, "{{{}}}", error_or.value());
|
||||
return Formatter<FormatString>::format(builder, "{}"sv, error_or.error());
|
||||
return Formatter<FormatString>::format(builder, "{{{}}}"sv, error_or.value());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue