1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 23:47:45 +00:00

AK: Remove StringBuilder::build() in favor of to_deprecated_string()

Having an alias function that only wraps another one is silly, and
keeping the more obvious name should flush out more uses of deprecated
strings.
No behavior change.
This commit is contained in:
Linus Groh 2023-01-26 18:58:09 +00:00
parent da81041e97
commit 6e7459322d
129 changed files with 213 additions and 219 deletions

View file

@ -17,7 +17,7 @@ DeprecatedString BlockQuote::render_to_html(bool) const
builder.append("<blockquote>\n"sv);
builder.append(m_contents->render_to_html());
builder.append("</blockquote>\n"sv);
return builder.build();
return builder.to_deprecated_string();
}
Vector<DeprecatedString> BlockQuote::render_lines_for_terminal(size_t view_width) const

View file

@ -51,7 +51,7 @@ DeprecatedString CodeBlock::render_to_html(bool) const
builder.append("</pre>\n"sv);
return builder.build();
return builder.to_deprecated_string();
}
Vector<DeprecatedString> CodeBlock::render_lines_for_terminal(size_t) const
@ -174,7 +174,7 @@ OwnPtr<CodeBlock> CodeBlock::parse_backticks(LineIterator& lines, Heading* curre
builder.append('\n');
}
return make<CodeBlock>(language, style, builder.build(), current_section);
return make<CodeBlock>(language, style, builder.to_deprecated_string(), current_section);
}
OwnPtr<CodeBlock> CodeBlock::parse_indent(LineIterator& lines)
@ -197,6 +197,6 @@ OwnPtr<CodeBlock> CodeBlock::parse_indent(LineIterator& lines)
builder.append('\n');
}
return make<CodeBlock>("", "", builder.build(), nullptr);
return make<CodeBlock>("", "", builder.to_deprecated_string(), nullptr);
}
}

View file

@ -20,7 +20,7 @@ DeprecatedString CommentBlock::render_to_html(bool) const
// TODO: This is probably incorrect, because we technically need to escape "--" in some form. However, Browser does not care about this.
builder.append("-->\n"sv);
return builder.build();
return builder.to_deprecated_string();
}
Vector<DeprecatedString> CommentBlock::render_lines_for_terminal(size_t) const
@ -69,7 +69,7 @@ OwnPtr<CommentBlock> CommentBlock::parse(LineIterator& lines)
line = *lines;
}
return make<CommentBlock>(builder.build());
return make<CommentBlock>(builder.to_deprecated_string());
}
}

View file

@ -37,7 +37,7 @@ DeprecatedString ContainerBlock::render_to_html(bool tight) const
}
}
return builder.build();
return builder.to_deprecated_string();
}
Vector<DeprecatedString> ContainerBlock::render_lines_for_terminal(size_t view_width) const
@ -97,7 +97,7 @@ OwnPtr<ContainerBlock> ContainerBlock::parse(LineIterator& lines)
auto flush_paragraph = [&] {
if (paragraph_text.is_empty())
return;
auto paragraph = make<Paragraph>(Text::parse(paragraph_text.build()));
auto paragraph = make<Paragraph>(Text::parse(paragraph_text.to_deprecated_string()));
blocks.append(move(paragraph));
paragraph_text.clear();
};

View file

@ -35,7 +35,7 @@ DeprecatedString Document::render_to_html(StringView extra_head_contents) const
</body>
</html>)~~~"sv);
return builder.build();
return builder.to_deprecated_string();
}
DeprecatedString Document::render_to_inline_html() const
@ -51,7 +51,7 @@ DeprecatedString Document::render_for_terminal(size_t view_width) const
builder.append("\n"sv);
}
return builder.build();
return builder.to_deprecated_string();
}
RecursionDecision Document::walk(Visitor& visitor) const

View file

@ -32,7 +32,7 @@ Vector<DeprecatedString> Heading::render_lines_for_terminal(size_t) const
break;
}
return Vector<DeprecatedString> { builder.build() };
return Vector<DeprecatedString> { builder.to_deprecated_string() };
}
RecursionDecision Heading::walk(Visitor& visitor) const

View file

@ -35,7 +35,7 @@ DeprecatedString List::render_to_html(bool) const
builder.appendff("</{}>\n", tag);
return builder.build();
return builder.to_deprecated_string();
}
Vector<DeprecatedString> List::render_lines_for_terminal(size_t view_width) const
@ -57,13 +57,13 @@ Vector<DeprecatedString> List::render_lines_for_terminal(size_t view_width) cons
builder.append(first_line);
lines.append(builder.build());
lines.append(builder.to_deprecated_string());
for (auto& line : item_lines) {
builder.clear();
builder.append(DeprecatedString::repeated(' ', item_indentation));
builder.append(line);
lines.append(builder.build());
lines.append(builder.to_deprecated_string());
}
}

View file

@ -25,7 +25,7 @@ DeprecatedString Paragraph::render_to_html(bool tight) const
builder.append('\n');
return builder.build();
return builder.to_deprecated_string();
}
Vector<DeprecatedString> Paragraph::render_lines_for_terminal(size_t) const

View file

@ -44,12 +44,12 @@ Vector<DeprecatedString> Table::render_lines_for_terminal(size_t view_width) con
write_aligned(col.header, width, col.alignment);
}
lines.append(builder.build());
lines.append(builder.to_deprecated_string());
builder.clear();
for (size_t i = 0; i < view_width; ++i)
builder.append('-');
lines.append(builder.build());
lines.append(builder.to_deprecated_string());
builder.clear();
for (size_t i = 0; i < m_row_count; ++i) {
@ -65,7 +65,7 @@ Vector<DeprecatedString> Table::render_lines_for_terminal(size_t view_width) con
size_t width = col.relative_width * unit_width_length;
write_aligned(cell, width, col.alignment);
}
lines.append(builder.build());
lines.append(builder.to_deprecated_string());
builder.clear();
}

View file

@ -266,14 +266,14 @@ DeprecatedString Text::render_to_html() const
{
StringBuilder builder;
m_node->render_to_html(builder);
return builder.build().trim(" \n\t"sv);
return builder.to_deprecated_string().trim(" \n\t"sv);
}
DeprecatedString Text::render_for_terminal() const
{
StringBuilder builder;
m_node->render_for_terminal(builder);
return builder.build().trim(" \n\t"sv);
return builder.to_deprecated_string().trim(" \n\t"sv);
}
RecursionDecision Text::walk(Visitor& visitor) const
@ -323,7 +323,7 @@ Vector<Text::Token> Text::tokenize(StringView str)
return;
tokens.append({
current_token.build(),
current_token.to_deprecated_string(),
left_flanking,
right_flanking,
punct_before,
@ -627,7 +627,7 @@ NonnullOwnPtr<Text::Node> Text::parse_link(Vector<Token>::ConstIterator& tokens)
if (*iterator == ")"sv) {
tokens = iterator;
return make<LinkNode>(is_image, move(link_text), address.build().trim_whitespace(), image_width, image_height);
return make<LinkNode>(is_image, move(link_text), address.to_deprecated_string().trim_whitespace(), image_width, image_height);
}
address.append(iterator->data);