mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:17:36 +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
|
@ -143,11 +143,11 @@ struct Formatter<PDF::LineCapStyle> : Formatter<StringView> {
|
|||
{
|
||||
switch (style) {
|
||||
case PDF::LineCapStyle::ButtCap:
|
||||
return Formatter<StringView>::format(builder, "LineCapStyle::ButtCap");
|
||||
return builder.put_string("LineCapStyle::ButtCap"sv);
|
||||
case PDF::LineCapStyle::RoundCap:
|
||||
return Formatter<StringView>::format(builder, "LineCapStyle::RoundCap");
|
||||
return builder.put_string("LineCapStyle::RoundCap"sv);
|
||||
case PDF::LineCapStyle::SquareCap:
|
||||
return Formatter<StringView>::format(builder, "LineCapStyle::SquareCap");
|
||||
return builder.put_string("LineCapStyle::SquareCap"sv);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -158,11 +158,11 @@ struct Formatter<PDF::LineJoinStyle> : Formatter<StringView> {
|
|||
{
|
||||
switch (style) {
|
||||
case PDF::LineJoinStyle::Miter:
|
||||
return Formatter<StringView>::format(builder, "LineJoinStyle::Miter");
|
||||
return builder.put_string("LineJoinStyle::Miter"sv);
|
||||
case PDF::LineJoinStyle::Round:
|
||||
return Formatter<StringView>::format(builder, "LineJoinStyle::Round");
|
||||
return builder.put_string("LineJoinStyle::Round"sv);
|
||||
case PDF::LineJoinStyle::Bevel:
|
||||
return Formatter<StringView>::format(builder, "LineJoinStyle::Bevel");
|
||||
return builder.put_string("LineJoinStyle::Bevel"sv);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -183,7 +183,7 @@ struct Formatter<PDF::LineDashPattern> : Formatter<StringView> {
|
|||
}
|
||||
|
||||
builder.appendff("] {}", pattern.phase);
|
||||
return Formatter<StringView>::format(format_builder, builder.to_string());
|
||||
return format_builder.put_string(builder.to_string());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -193,21 +193,21 @@ struct Formatter<PDF::TextRenderingMode> : Formatter<StringView> {
|
|||
{
|
||||
switch (style) {
|
||||
case PDF::TextRenderingMode::Fill:
|
||||
return Formatter<StringView>::format(builder, "TextRenderingMode::Fill");
|
||||
return builder.put_string("TextRenderingMode::Fill"sv);
|
||||
case PDF::TextRenderingMode::Stroke:
|
||||
return Formatter<StringView>::format(builder, "TextRenderingMode::Stroke");
|
||||
return builder.put_string("TextRenderingMode::Stroke"sv);
|
||||
case PDF::TextRenderingMode::FillThenStroke:
|
||||
return Formatter<StringView>::format(builder, "TextRenderingMode::FillThenStroke");
|
||||
return builder.put_string("TextRenderingMode::FillThenStroke"sv);
|
||||
case PDF::TextRenderingMode::Invisible:
|
||||
return Formatter<StringView>::format(builder, "TextRenderingMode::Invisible");
|
||||
return builder.put_string("TextRenderingMode::Invisible"sv);
|
||||
case PDF::TextRenderingMode::FillAndClip:
|
||||
return Formatter<StringView>::format(builder, "TextRenderingMode::FillAndClip");
|
||||
return builder.put_string("TextRenderingMode::FillAndClip"sv);
|
||||
case PDF::TextRenderingMode::StrokeAndClip:
|
||||
return Formatter<StringView>::format(builder, "TextRenderingMode::StrokeAndClip");
|
||||
return builder.put_string("TextRenderingMode::StrokeAndClip"sv);
|
||||
case PDF::TextRenderingMode::FillStrokeAndClip:
|
||||
return Formatter<StringView>::format(builder, "TextRenderingMode::FillStrokeAndClip");
|
||||
return builder.put_string("TextRenderingMode::FillStrokeAndClip"sv);
|
||||
case PDF::TextRenderingMode::Clip:
|
||||
return Formatter<StringView>::format(builder, "TextRenderingMode::Clip");
|
||||
return builder.put_string("TextRenderingMode::Clip"sv);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -229,7 +229,7 @@ struct Formatter<PDF::TextState> : Formatter<StringView> {
|
|||
builder.appendff(" rise={}\n", state.rise);
|
||||
builder.appendff(" knockout={}\n", state.knockout);
|
||||
builder.append(" }");
|
||||
return Formatter<StringView>::format(format_builder, builder.to_string());
|
||||
return format_builder.put_string(builder.to_string());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -249,7 +249,7 @@ struct Formatter<PDF::GraphicsState> : Formatter<StringView> {
|
|||
builder.appendff(" line_dash_pattern={}\n", state.line_dash_pattern);
|
||||
builder.appendff(" text_state={}\n", state.text_state);
|
||||
builder.append("}");
|
||||
return Formatter<StringView>::format(format_builder, builder.to_string());
|
||||
return format_builder.put_string(builder.to_string());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue