mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:37:45 +00:00
Meta+Userland: Simplify some formatters
These are mostly minor mistakes I've encountered while working on the removal of StringView(char const*). The usage of builder.put_string over Format<FormatString>::format is preferrable as it will avoid the indirection altogether when there's no formatting to be done. Similarly, there is no need to do format(builder, "{}", number) when builder.put_u64(number) works equally well. Additionally a few Strings where only constant strings were used are replaced with StringViews.
This commit is contained in:
parent
7da00bfa8d
commit
7456904a39
9 changed files with 64 additions and 67 deletions
|
@ -401,24 +401,24 @@ ErrorOr<void> AK::Formatter<Crypto::ASN1::DecodeError>::format(FormatBuilder& fm
|
|||
|
||||
switch (error) {
|
||||
case DecodeError::NoInput:
|
||||
return Formatter<StringView>::format(fmtbuilder, "DecodeError(No input provided)");
|
||||
return fmtbuilder.put_string("DecodeError(No input provided)"sv);
|
||||
case DecodeError::NonConformingType:
|
||||
return Formatter<StringView>::format(fmtbuilder, "DecodeError(Tried to read with a non-conforming type)");
|
||||
return fmtbuilder.put_string("DecodeError(Tried to read with a non-conforming type)"sv);
|
||||
case DecodeError::EndOfStream:
|
||||
return Formatter<StringView>::format(fmtbuilder, "DecodeError(End of stream)");
|
||||
return fmtbuilder.put_string("DecodeError(End of stream)"sv);
|
||||
case DecodeError::NotEnoughData:
|
||||
return Formatter<StringView>::format(fmtbuilder, "DecodeError(Not enough data)");
|
||||
return fmtbuilder.put_string("DecodeError(Not enough data)"sv);
|
||||
case DecodeError::EnteringNonConstructedTag:
|
||||
return Formatter<StringView>::format(fmtbuilder, "DecodeError(Tried to enter a primitive tag)");
|
||||
return fmtbuilder.put_string("DecodeError(Tried to enter a primitive tag)"sv);
|
||||
case DecodeError::LeavingMainContext:
|
||||
return Formatter<StringView>::format(fmtbuilder, "DecodeError(Tried to leave the main context)");
|
||||
return fmtbuilder.put_string("DecodeError(Tried to leave the main context)"sv);
|
||||
case DecodeError::InvalidInputFormat:
|
||||
return Formatter<StringView>::format(fmtbuilder, "DecodeError(Input data contained invalid syntax/data)");
|
||||
return fmtbuilder.put_string("DecodeError(Input data contained invalid syntax/data)"sv);
|
||||
case DecodeError::Overflow:
|
||||
return Formatter<StringView>::format(fmtbuilder, "DecodeError(Construction would overflow)");
|
||||
return fmtbuilder.put_string("DecodeError(Construction would overflow)"sv);
|
||||
case DecodeError::UnsupportedFormat:
|
||||
return Formatter<StringView>::format(fmtbuilder, "DecodeError(Input data format not supported by this parser)");
|
||||
return fmtbuilder.put_string("DecodeError(Input data format not supported by this parser)"sv);
|
||||
default:
|
||||
return Formatter<StringView>::format(fmtbuilder, "DecodeError(Unknown)");
|
||||
return fmtbuilder.put_string("DecodeError(Unknown)"sv);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue