1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 18:37:34 +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

@ -48,7 +48,7 @@ static ErrorOr<DeprecatedString> sem_name_to_path(char const* name)
StringBuilder builder;
TRY(builder.try_append(sem_path_prefix));
TRY(builder.try_append(name_view));
return builder.build();
return builder.to_deprecated_string();
}
struct NamedSemaphore {

View file

@ -641,7 +641,7 @@ int ptsname_r(int fd, char* buffer, size_t size)
return -1;
}
memset(buffer, 0, devpts_path_builder.length() + 1);
auto full_devpts_path_string = devpts_path_builder.build();
auto full_devpts_path_string = devpts_path_builder.to_deprecated_string();
if (!full_devpts_path_string.copy_characters_to_buffer(buffer, size)) {
errno = ERANGE;
return -1;

View file

@ -124,7 +124,7 @@ void vsyslog_r(int priority, struct syslog_data* data, char const* message, va_l
combined.appendff("{}: ", get_syslog_ident(data));
combined.appendvf(message, args);
DeprecatedString combined_string = combined.build();
auto combined_string = combined.to_deprecated_string();
if (data->logopt & LOG_CONS)
dbgputstr(combined_string.characters(), combined_string.length());

View file

@ -390,7 +390,7 @@ size_t strftime(char* destination, size_t max_size, char const* format, const st
return 0;
}
auto str = builder.build();
auto str = builder.to_deprecated_string();
bool fits = str.copy_characters_to_buffer(destination, max_size);
return fits ? str.length() : 0;
}

View file

@ -137,6 +137,6 @@ struct AK::Formatter<Cards::CardStack> : Formatter<FormatString> {
first_card = false;
}
return Formatter<FormatString>::format(builder, "{:<10} {:>16}: {}"sv, type, stack.bounding_box(), cards.build());
return Formatter<FormatString>::format(builder, "{:<10} {:>16}: {}"sv, type, stack.bounding_box(), cards.to_deprecated_string());
}
};

View file

@ -82,7 +82,7 @@ DeprecatedString Square::to_algebraic() const
StringBuilder builder;
builder.append(file + 'a');
builder.append(rank + '1');
return builder.build();
return builder.to_deprecated_string();
}
Move::Move(StringView long_algebraic)
@ -98,7 +98,7 @@ DeprecatedString Move::to_long_algebraic() const
builder.append(from.to_algebraic());
builder.append(to.to_algebraic());
builder.append(char_for_piece(promote_to).to_lowercase());
return builder.build();
return builder.to_deprecated_string();
}
Move Move::from_algebraic(StringView algebraic, const Color turn, Board const& board)
@ -216,7 +216,7 @@ DeprecatedString Move::to_algebraic() const
else if (is_check)
builder.append('+');
return builder.build();
return builder.to_deprecated_string();
}
Board::Board()

View file

@ -105,7 +105,7 @@ DeprecatedString SetOptionCommand::to_deprecated_string() const
builder.append(value().value());
}
builder.append('\n');
return builder.build();
return builder.to_deprecated_string();
}
PositionCommand PositionCommand::from_string(StringView command)
@ -141,7 +141,7 @@ DeprecatedString PositionCommand::to_deprecated_string() const
builder.append(move.to_long_algebraic());
}
builder.append('\n');
return builder.build();
return builder.to_deprecated_string();
}
GoCommand GoCommand::from_string(StringView command)
@ -227,7 +227,7 @@ DeprecatedString GoCommand::to_deprecated_string() const
builder.append(" infinite"sv);
builder.append('\n');
return builder.build();
return builder.to_deprecated_string();
}
StopCommand StopCommand::from_string(StringView command)
@ -256,9 +256,9 @@ IdCommand IdCommand::from_string(StringView command)
}
if (tokens[1] == "name") {
return IdCommand(Type::Name, value.build());
return IdCommand(Type::Name, value.to_deprecated_string());
} else if (tokens[1] == "author") {
return IdCommand(Type::Author, value.build());
return IdCommand(Type::Author, value.to_deprecated_string());
}
VERIFY_NOT_REACHED();
}
@ -274,7 +274,7 @@ DeprecatedString IdCommand::to_deprecated_string() const
}
builder.append(value());
builder.append('\n');
return builder.build();
return builder.to_deprecated_string();
}
UCIOkCommand UCIOkCommand::from_string(StringView command)
@ -317,7 +317,7 @@ DeprecatedString BestMoveCommand::to_deprecated_string() const
builder.append("bestmove "sv);
builder.append(move().to_long_algebraic());
builder.append('\n');
return builder.build();
return builder.to_deprecated_string();
}
InfoCommand InfoCommand::from_string([[maybe_unused]] StringView command)

View file

@ -81,7 +81,7 @@ Vector<DeprecatedString> const& ShellComprehensionEngine::DocumentData::sourced_
auto name_list = const_cast<::Shell::AST::Node*>(filename.ptr())->run(nullptr)->resolve_as_list(nullptr);
StringBuilder builder;
builder.join(' ', name_list);
sourced_files.set(builder.build());
sourced_files.set(builder.to_deprecated_string());
}
}
}

View file

@ -39,7 +39,7 @@ static DeprecatedString get_salt()
auto salt_string = MUST(encode_base64({ random_data, sizeof(random_data) }));
builder.append(salt_string);
return builder.build();
return builder.to_deprecated_string();
}
static Vector<gid_t> get_extra_gids(passwd const& pwd)
@ -196,7 +196,7 @@ void Account::set_password_enabled(bool enabled)
StringBuilder builder;
builder.append('!');
builder.append(m_password_hash);
m_password_hash = builder.build();
m_password_hash = builder.to_deprecated_string();
}
}

View file

@ -77,7 +77,7 @@ bool ArgsParser::parse(int argc, char* const* argv, FailureBehavior failure_beha
}
long_options.append({ 0, 0, 0, 0 });
DeprecatedString short_options = short_options_builder.build();
auto short_options = short_options_builder.to_deprecated_string();
while (true) {
int c = getopt_long(argc, argv, short_options.characters(), long_options.data(), nullptr);

View file

@ -273,7 +273,7 @@ DeprecatedString DateTime::to_deprecated_string(StringView format) const
}
}
return builder.build();
return builder.to_deprecated_string();
}
Optional<DateTime> DateTime::parse(StringView format, DeprecatedString const& string)

View file

@ -394,7 +394,7 @@ static DeprecatedString get_duplicate_name(DeprecatedString const& path, int dup
if (!lexical_path.extension().is_empty()) {
duplicated_name.appendff(".{}", lexical_path.extension());
}
return duplicated_name.build();
return duplicated_name.to_deprecated_string();
}
ErrorOr<void, File::CopyError> File::copy_file_or_directory(DeprecatedString const& dst_path, DeprecatedString const& src_path, RecursionMode recursion_mode, LinkMode link_mode, AddDuplicateFileMarker add_duplicate_file_marker, PreserveMode preserve_mode)

View file

@ -131,7 +131,7 @@ DeprecatedString Backtrace::Entry::to_deprecated_string(bool color) const
builder.appendff("{:p}: ", eip);
if (object_name.is_empty()) {
builder.append("???"sv);
return builder.build();
return builder.to_deprecated_string();
}
builder.appendff("[{}] {}", object_name, function_name.is_empty() ? "???" : function_name);
builder.append(" ("sv);
@ -158,7 +158,7 @@ DeprecatedString Backtrace::Entry::to_deprecated_string(bool color) const
builder.append(')');
return builder.build();
return builder.to_deprecated_string();
}
}

View file

@ -32,8 +32,8 @@ void SemanticSyntaxHighlighter::rehighlight(Palette const& palette)
for (Cpp::Token const& token : m_saved_tokens)
previous_tokens_as_lines.appendff("{}\n", token.type_as_deprecated_string());
auto previous = previous_tokens_as_lines.build();
auto current = current_tokens_as_lines.build();
auto previous = previous_tokens_as_lines.to_deprecated_string();
auto current = current_tokens_as_lines.to_deprecated_string();
// FIXME: Computing the diff on the entire document's tokens is quite inefficient.
// An improvement over this could be only including the tokens that are in edited text ranges in the diff.

View file

@ -79,7 +79,7 @@ public:
StringBuilder builder;
builder.append("HMAC-"sv);
builder.append(m_inner_hasher.class_name());
return builder.build();
return builder.to_deprecated_string();
}
#endif

View file

@ -30,7 +30,7 @@ DeprecatedString AESCipherBlock::to_deprecated_string() const
StringBuilder builder;
for (auto value : m_data)
builder.appendff("{:02x}", value);
return builder.build();
return builder.to_deprecated_string();
}
DeprecatedString AESCipherKey::to_deprecated_string() const
@ -38,7 +38,7 @@ DeprecatedString AESCipherKey::to_deprecated_string() const
StringBuilder builder;
for (size_t i = 0; i < (rounds() + 1) * 4; ++i)
builder.appendff("{:02x}", m_rd_keys[i]);
return builder.build();
return builder.to_deprecated_string();
}
#endif

View file

@ -35,7 +35,7 @@ public:
StringBuilder builder;
builder.append(this->cipher().class_name());
builder.append("_CBC"sv);
return builder.build();
return builder.to_deprecated_string();
}
#endif

View file

@ -110,7 +110,7 @@ public:
StringBuilder builder;
builder.append(this->cipher().class_name());
builder.append("_CTR"sv);
return builder.build();
return builder.to_deprecated_string();
}
#endif

View file

@ -50,7 +50,7 @@ public:
StringBuilder builder;
builder.append(this->cipher().class_name());
builder.append("_GCM"sv);
return builder.build();
return builder.to_deprecated_string();
}
#endif

View file

@ -1010,7 +1010,7 @@ DeprecatedString Parser::display_product_name() const
break;
str.append((char)byte);
}
product_name = str.build();
product_name = str.to_deprecated_string();
return IterationDecision::Break;
});
if (result.is_error()) {
@ -1033,7 +1033,7 @@ DeprecatedString Parser::display_product_serial_number() const
break;
str.append((char)byte);
}
product_name = str.build();
product_name = str.to_deprecated_string();
return IterationDecision::Break;
});
if (result.is_error()) {

View file

@ -118,7 +118,7 @@ void AutocompleteProvider::provide_completions(Function<void(Vector<CodeComprehe
fuzzy_str_builder.append(character);
fuzzy_str_builder.append('*');
}
return fuzzy_str_builder.build();
return fuzzy_str_builder.to_deprecated_string();
};
Vector<CodeComprehension::AutocompleteResultEntry> class_entries, identifier_entries;

View file

@ -854,7 +854,7 @@ void InsertTextCommand::perform_formatting(TextDocument::Client const& client)
++column;
}
}
m_text = builder.build();
m_text = builder.to_deprecated_string();
}
void InsertTextCommand::redo()

View file

@ -25,7 +25,7 @@ DeprecatedString Document::render_to_html() const
}
html_builder.append("</body>"sv);
html_builder.append("</html>"sv);
return html_builder.build();
return html_builder.to_deprecated_string();
}
NonnullRefPtr<Document> Document::parse(StringView lines, const URL& url)

View file

@ -14,7 +14,7 @@ DeprecatedString Text::render_to_html() const
StringBuilder builder;
builder.append(escape_html_entities(m_text));
builder.append("<br>\n"sv);
return builder.build();
return builder.to_deprecated_string();
}
DeprecatedString Heading::render_to_html() const
@ -31,7 +31,7 @@ DeprecatedString UnorderedList::render_to_html() const
builder.append("<li>"sv);
builder.append(escape_html_entities(m_text.substring_view(1, m_text.length() - 1)));
builder.append("</li>"sv);
return builder.build();
return builder.to_deprecated_string();
}
DeprecatedString Control::render_to_html() const
@ -81,7 +81,7 @@ DeprecatedString Link::render_to_html() const
builder.append("\">"sv);
builder.append(escape_html_entities(m_name));
builder.append("</a><br>\n"sv);
return builder.build();
return builder.to_deprecated_string();
}
DeprecatedString Preformatted::render_to_html() const
@ -90,7 +90,7 @@ DeprecatedString Preformatted::render_to_html() const
builder.append(escape_html_entities(m_text));
builder.append('\n');
return builder.build();
return builder.to_deprecated_string();
}
}

View file

@ -371,7 +371,7 @@ void Job::on_socket_connected()
builder.append(existing_value.value());
builder.append(',');
builder.append(value);
m_headers.set(name, builder.build());
m_headers.set(name, builder.to_deprecated_string());
} else {
m_headers.set(name, value);
}

View file

@ -73,7 +73,7 @@ static DeprecatedString convert_enumeration_value_to_cpp_enum_member(DeprecatedS
builder.append('_');
names_already_seen.set(builder.string_view());
return builder.build();
return builder.to_deprecated_string();
}
namespace IDL {

View file

@ -306,7 +306,7 @@ RefPtr<Promise<Optional<SolidResponse>>> Client::store(StoreMethod method, Seque
flags_builder.join(' ', flags);
flags_builder.append(')');
auto command = Command { uid ? CommandType::UIDStore : CommandType::Store, m_current_command, { sequence_set.serialize(), data_item_name.build(), flags_builder.build() } };
auto command = Command { uid ? CommandType::UIDStore : CommandType::Store, m_current_command, { sequence_set.serialize(), data_item_name.to_deprecated_string(), flags_builder.to_deprecated_string() } };
return cast_promise<SolidResponse>(send_command(move(command)));
}
RefPtr<Promise<Optional<SolidResponse>>> Client::search(Optional<DeprecatedString> charset, Vector<SearchKey>&& keys, bool uid)
@ -363,7 +363,7 @@ RefPtr<Promise<Optional<SolidResponse>>> Client::status(StringView mailbox, Vect
types_list.append('(');
types_list.join(' ', args);
types_list.append(')');
auto command = Command { CommandType::Status, m_current_command, { mailbox, types_list.build() } };
auto command = Command { CommandType::Status, m_current_command, { mailbox, types_list.to_deprecated_string() } };
return cast_promise<SolidResponse>(send_command(move(command)));
}
@ -375,7 +375,7 @@ RefPtr<Promise<Optional<SolidResponse>>> Client::append(StringView mailbox, Mess
flags_sb.append('(');
flags_sb.join(' ', flags.value());
flags_sb.append(')');
args.append(flags_sb.build());
args.append(flags_sb.to_deprecated_string());
}
if (date_time.has_value())
args.append(date_time.value().to_deprecated_string("\"%d-%b-%Y %H:%M:%S +0000\""sv));

View file

@ -41,7 +41,7 @@ DeprecatedString FetchCommand::DataItem::Section::serialize() const
first = false;
}
headers_builder.append(')');
return headers_builder.build();
return headers_builder.to_deprecated_string();
}
case SectionType::Text:
return "TEXT";
@ -57,7 +57,7 @@ DeprecatedString FetchCommand::DataItem::Section::serialize() const
if (ends_with_mime) {
sb.append(".MIME"sv);
}
return sb.build();
return sb.to_deprecated_string();
}
}
VERIFY_NOT_REACHED();
@ -82,7 +82,7 @@ DeprecatedString FetchCommand::DataItem::serialize() const
sb.appendff("<{}.{}>", start, octets);
}
return sb.build();
return sb.to_deprecated_string();
}
case DataItemType::BodyStructure:
return "BODYSTRUCTURE";
@ -111,7 +111,7 @@ DeprecatedString FetchCommand::serialize()
first = false;
}
return AK::DeprecatedString::formatted("{} ({})", sequence_builder.build(), data_items_builder.build());
return AK::DeprecatedString::formatted("{} ({})", sequence_builder.to_deprecated_string(), data_items_builder.to_deprecated_string());
}
DeprecatedString serialize_astring(StringView string)
{
@ -164,7 +164,7 @@ DeprecatedString SearchKey::serialize() const
sb.append(item->serialize());
first = false;
}
return sb.build();
return sb.to_deprecated_string();
},
[&](Seen const&) { return DeprecatedString("SEEN"); },
[&](SentBefore const& x) { return DeprecatedString::formatted("SENTBEFORE {}", x.date.to_deprecated_string("%d-%b-%Y"sv)); },

View file

@ -83,7 +83,7 @@ void Parser::parse_response_done()
}
consume("\r\n"sv);
m_response.m_response_text = response_data.build();
m_response.m_response_text = response_data.to_deprecated_string();
}
void Parser::consume(StringView x)

View file

@ -3762,7 +3762,7 @@ Completion TemplateLiteral::execute(Interpreter& interpreter) const
}
// 7. Return the string-concatenation of head, middle, and tail.
return Value { PrimitiveString::create(vm, string_builder.build()) };
return Value { PrimitiveString::create(vm, string_builder.to_deprecated_string()) };
}
void TaggedTemplateLiteral::dump(int indent) const

View file

@ -142,7 +142,7 @@ void MergeBlocks::perform(PassPipelineExecutable& executable)
builder.append(entry->name());
}
auto new_block = BasicBlock::create(builder.build(), size);
auto new_block = BasicBlock::create(builder.to_deprecated_string(), size);
auto& block = *new_block;
auto first_successor_position = replace_blocks(successors, *new_block);
VERIFY(first_successor_position.has_value());

View file

@ -32,7 +32,7 @@ DeprecatedString ParserError::source_location_hint(StringView source, char const
for (size_t i = 0; i < position.value().column - 1; ++i)
builder.append(spacer);
builder.append(indicator);
return builder.build();
return builder.to_deprecated_string();
}
}

View file

@ -57,7 +57,7 @@ DeprecatedString Date::iso_date_string() const
builder.appendff("{:03}", ms_from_time(m_date_value));
builder.append('Z');
return builder.build();
return builder.to_deprecated_string();
}
// DayWithinYear(t), https://tc39.es/ecma262/#eqn-DayWithinYear

View file

@ -95,7 +95,7 @@ DeprecatedString Error::stack_string() const
}
}
return stack_string_builder.build();
return stack_string_builder.to_deprecated_string();
}
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \

View file

@ -413,7 +413,7 @@ static ThrowCompletionOr<DeprecatedString> encode(VM& vm, DeprecatedString const
VERIFY(nwritten > 0);
}
}
return encoded_builder.build();
return encoded_builder.to_deprecated_string();
}
// 19.2.6.1.2 Decode ( string, reservedSet ), https://tc39.es/ecma262/#sec-decode
@ -471,7 +471,7 @@ static ThrowCompletionOr<DeprecatedString> decode(VM& vm, DeprecatedString const
}
if (expected_continuation_bytes > 0)
return vm.throw_completion<URIError>(ErrorType::URIMalformed);
return decoded_builder.build();
return decoded_builder.to_deprecated_string();
}
// 19.2.6.4 encodeURI ( uri ), https://tc39.es/ecma262/#sec-encodeuri-uri
@ -521,7 +521,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::escape)
}
escaped.appendff("%u{:04X}", code_point);
}
return PrimitiveString::create(vm, escaped.build());
return PrimitiveString::create(vm, escaped.to_deprecated_string());
}
// B.2.1.2 unescape ( string ), https://tc39.es/ecma262/#sec-unescape-string
@ -543,7 +543,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::unescape)
}
unescaped.append_code_point(code_point);
}
return PrimitiveString::create(vm, unescaped.build());
return PrimitiveString::create(vm, unescaped.to_deprecated_string());
}
}

View file

@ -55,7 +55,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationFormatPrototype::format)
}
// 7. Return result.
return PrimitiveString::create(vm, result.build());
return PrimitiveString::create(vm, result.to_deprecated_string());
}
// 1.4.4 Intl.DurationFormat.prototype.formatToParts ( duration ), https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.prototype.formatToParts

View file

@ -237,7 +237,7 @@ ThrowCompletionOr<DeprecatedString> format_relative_time(VM& vm, RelativeTimeFor
}
// 4. Return result.
return result.build();
return result.to_deprecated_string();
}
// 17.5.5 FormatRelativeTimeToParts ( relativeTimeFormat, value, unit ), https://tc39.es/ecma402/#sec-FormatRelativeTimeToParts

View file

@ -116,7 +116,7 @@ ErrorOr<DeprecatedString, ParseRegexPatternError> parse_regex_pattern(StringView
builder.append_code_point(code_unit);
}
return builder.build();
return builder.to_deprecated_string();
}
ThrowCompletionOr<DeprecatedString> parse_regex_pattern(VM& vm, StringView pattern, bool unicode, bool unicode_sets)

View file

@ -820,13 +820,13 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace)
// 15. If nextSourcePosition ≥ lengthS, return accumulatedResult.
if (next_source_position >= string.length_in_code_units())
return PrimitiveString::create(vm, accumulated_result.build());
return PrimitiveString::create(vm, accumulated_result.to_deprecated_string());
// 16. Return the string-concatenation of accumulatedResult and the substring of S from nextSourcePosition.
auto substring = string.substring_view(next_source_position);
accumulated_result.append(substring);
return PrimitiveString::create(vm, accumulated_result.build());
return PrimitiveString::create(vm, accumulated_result.to_deprecated_string());
}
// 22.2.5.12 RegExp.prototype [ @@search ] ( string ), https://tc39.es/ecma262/#sec-regexp.prototype-@@search

View file

@ -94,7 +94,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::raw)
builder.append(next_sub);
}
}
return PrimitiveString::create(vm, builder.build());
return PrimitiveString::create(vm, builder.to_deprecated_string());
}
// 22.1.2.1 String.fromCharCode ( ...codeUnits ), https://tc39.es/ecma262/#sec-string.fromcharcode

View file

@ -63,7 +63,7 @@ double Token::double_value() const
builder.append(ch);
}
DeprecatedString value_string = builder.to_deprecated_string();
auto value_string = builder.to_deprecated_string();
if (value_string[0] == '0' && value_string.length() >= 2) {
if (value_string[1] == 'x' || value_string[1] == 'X') {
// hexadecimal

View file

@ -372,7 +372,7 @@ void Editor::insert(const u32 cp)
{
StringBuilder builder;
builder.append(Utf32View(&cp, 1));
auto str = builder.build();
auto str = builder.to_deprecated_string();
if (m_pending_chars.try_append(str.characters(), str.length()).is_error())
return;
@ -1750,7 +1750,7 @@ DeprecatedString Style::to_deprecated_string() const
builder.append('}');
return builder.build();
return builder.to_deprecated_string();
}
ErrorOr<void> VT::apply_style(Style const& style, Core::Stream::Stream& stream, bool is_starting)
@ -2182,7 +2182,7 @@ DeprecatedString Editor::line(size_t up_to_index) const
{
StringBuilder builder;
builder.append(Utf32View { m_buffer.data(), min(m_buffer.size(), up_to_index) });
return builder.build();
return builder.to_deprecated_string();
}
void Editor::remove_at_index(size_t index)

View file

@ -36,7 +36,7 @@ void Editor::search_forwards()
ScopedValueRollback inline_search_cursor_rollback { m_inline_search_cursor };
StringBuilder builder;
builder.append(Utf32View { m_buffer.data(), m_inline_search_cursor });
DeprecatedString search_phrase = builder.to_deprecated_string();
auto search_phrase = builder.to_deprecated_string();
if (m_search_offset_state == SearchOffsetState::Backwards)
--m_search_offset;
if (m_search_offset > 0) {
@ -63,7 +63,7 @@ void Editor::search_backwards()
ScopedValueRollback inline_search_cursor_rollback { m_inline_search_cursor };
StringBuilder builder;
builder.append(Utf32View { m_buffer.data(), m_inline_search_cursor });
DeprecatedString search_phrase = builder.to_deprecated_string();
auto search_phrase = builder.to_deprecated_string();
if (m_search_offset_state == SearchOffsetState::Forwards)
++m_search_offset;
if (search(search_phrase, true)) {
@ -237,7 +237,7 @@ void Editor::enter_search()
StringBuilder builder;
builder.append(Utf32View { search_editor.buffer().data(), search_editor.buffer().size() });
if (!search(builder.build(), false, false)) {
if (!search(builder.to_deprecated_string(), false, false)) {
m_chars_touched_in_the_middle = m_buffer.size();
m_refresh_needed = true;
m_buffer.clear();

View file

@ -290,7 +290,7 @@ static ErrorOr<Optional<String>> format_time_zone_offset(StringView locale, Cale
}
// The digits used for hours, minutes and seconds fields in this format are the locale's default decimal digits.
auto result = TRY(replace_digits_for_number_system(*number_system, builder.build()));
auto result = TRY(replace_digits_for_number_system(*number_system, builder.to_deprecated_string()));
return TRY(String::from_utf8(formats->gmt_format)).replace("{0}"sv, result, ReplaceMode::FirstOnly);
}

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);

View file

@ -273,7 +273,7 @@ public:
StringBuilder builder;
for (auto ch : data)
builder.append(ch); // Note: The type conversion is intentional.
optional_string_storage = builder.build();
optional_string_storage = builder.to_deprecated_string();
return RegexStringView { T { *optional_string_storage } };
},
[&](Utf32View) {

View file

@ -96,7 +96,7 @@ DeprecatedString Regex<Parser>::error_string(Optional<DeprecatedString> message)
eb.append(' ');
eb.appendff("^---- {}", message.value_or(get_error_string(parser_result.error)));
return eb.build();
return eb.to_deprecated_string();
}
template<typename Parser>

View file

@ -598,7 +598,7 @@ ALWAYS_INLINE bool PosixExtendedParser::parse_repetition_symbol(ByteCode& byteco
number_builder.append(consume().value());
}
auto maybe_minimum = number_builder.build().to_uint();
auto maybe_minimum = number_builder.to_deprecated_string().to_uint();
if (!maybe_minimum.has_value())
return set_error(Error::InvalidBraceContent);
@ -627,7 +627,7 @@ ALWAYS_INLINE bool PosixExtendedParser::parse_repetition_symbol(ByteCode& byteco
number_builder.append(consume().value());
}
if (!number_builder.is_empty()) {
auto value = number_builder.build().to_uint();
auto value = number_builder.to_deprecated_string().to_uint();
if (!value.has_value() || minimum > value.value() || *value > s_maximum_repetition_count)
return set_error(Error::InvalidBraceContent);
@ -2530,7 +2530,7 @@ DeprecatedFlyString ECMA262Parser::read_capture_group_specifier(bool take_starti
builder.append_code_point(code_point);
}
DeprecatedFlyString name = builder.build();
DeprecatedFlyString name = builder.to_deprecated_string();
if (!hit_end || name.is_empty())
set_error(Error::InvalidNameForCaptureGroup);

View file

@ -211,7 +211,7 @@ ResultOr<Value> MatchExpression::evaluate(ExecutionContext& context) const
builder.append('$');
// FIXME: We should probably cache this regex.
auto regex = Regex<PosixBasic>(builder.build());
auto regex = Regex<PosixBasic>(builder.to_deprecated_string());
auto result = regex.match(lhs_value.to_deprecated_string(), PosixFlags::Insensitive | PosixFlags::Unicode);
return Value(invert_expression() ? !result.success : result.success);
}
@ -226,7 +226,7 @@ ResultOr<Value> MatchExpression::evaluate(ExecutionContext& context) const
builder.append("Regular expression: "sv);
builder.append(get_error_string(err));
return Result { SQLCommand::Unknown, SQLErrorCode::SyntaxError, builder.build() };
return Result { SQLCommand::Unknown, SQLErrorCode::SyntaxError, builder.to_deprecated_string() };
}
auto result = regex.match(lhs_value.to_deprecated_string(), PosixFlags::Insensitive | PosixFlags::Unicode);

View file

@ -109,7 +109,7 @@ Token Lexer::next()
}
}
Token token(token_type, current_token.build(),
Token token(token_type, current_token.to_deprecated_string(),
{ value_start_line_number, value_start_column_number },
{ m_line_number, m_line_column });

View file

@ -41,7 +41,7 @@ DeprecatedString Result::error_string() const
builder.append(error_description);
}
return builder.build();
return builder.to_deprecated_string();
}
}

View file

@ -364,7 +364,7 @@ void TreeNode::dump_if(int flag, DeprecatedString&& msg)
builder.append(", leaf"sv);
}
builder.append(')');
dbgln(builder.build());
dbgln(builder.to_deprecated_string());
}
void TreeNode::list_node(int indent)

View file

@ -173,7 +173,7 @@ DeprecatedString Tuple::to_deprecated_string() const
if (pointer() != 0) {
builder.appendff(":{}", pointer());
}
return builder.build();
return builder.to_deprecated_string();
}
void Tuple::copy_from(Tuple const& other)

View file

@ -221,7 +221,7 @@ DeprecatedString Value::to_deprecated_string() const
builder.join(',', value.values);
builder.append(')');
return builder.build();
return builder.to_deprecated_string();
});
}

View file

@ -92,7 +92,7 @@ public:
cert_name.append("/CN="sv);
cert_name.append(subject.subject);
}
return cert_name.build();
return cert_name.to_deprecated_string();
}
DeprecatedString issuer_identifier_string() const
@ -122,7 +122,7 @@ public:
cert_name.append("/CN="sv);
cert_name.append(issuer.subject);
}
return cert_name.build();
return cert_name.to_deprecated_string();
}
};

View file

@ -229,7 +229,7 @@ DeprecatedString DOMTokenList::value() const
{
StringBuilder builder;
builder.join(' ', m_token_set);
return builder.build();
return builder.to_deprecated_string();
}
// https://dom.spec.whatwg.org/#ref-for-concept-element-attributes-set-value%E2%91%A2

View file

@ -386,7 +386,7 @@ WebIDL::ExceptionOr<void> Document::write(Vector<DeprecatedString> const& string
StringBuilder builder;
builder.join(""sv, strings);
return run_the_document_write_steps(builder.build());
return run_the_document_write_steps(builder.to_deprecated_string());
}
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-writeln
@ -396,7 +396,7 @@ WebIDL::ExceptionOr<void> Document::writeln(Vector<DeprecatedString> const& stri
builder.join(""sv, strings);
builder.append("\n"sv);
return run_the_document_write_steps(builder.build());
return run_the_document_write_steps(builder.to_deprecated_string());
}
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#document-write-steps

View file

@ -270,7 +270,7 @@ DeprecatedString Node::child_text_content() const
if (is<Text>(child))
builder.append(verify_cast<Text>(child).text_content());
});
return builder.build();
return builder.to_deprecated_string();
}
// https://dom.spec.whatwg.org/#concept-tree-root

View file

@ -147,7 +147,7 @@ ErrorOr<Optional<Vector<DeprecatedString>>> get_decode_and_split_header_value(Re
}
// 3. Remove all HTTP tab or space from the start and end of temporaryValue.
auto temporary_value = temporary_value_builder.build().trim(HTTP_TAB_OR_SPACE, TrimMode::Both);
auto temporary_value = temporary_value_builder.to_deprecated_string().trim(HTTP_TAB_OR_SPACE, TrimMode::Both);
// 4. Append temporaryValue to values.
values.append(move(temporary_value));

View file

@ -420,7 +420,7 @@ CanvasRenderingContext2D::PreparedText CanvasRenderingContext2D::prepare_text(De
for (auto c : text) {
builder.append(Infra::is_ascii_whitespace(c) ? ' ' : c);
}
DeprecatedString replaced_text = builder.build();
auto replaced_text = builder.to_deprecated_string();
// 3. Let font be the current font of target, as given by that object's font attribute.
// FIXME: Once we have CanvasTextDrawingStyles, implement font selection.

View file

@ -2816,7 +2816,7 @@ void HTMLTokenizer::insert_input_at_insertion_point(DeprecatedString const& inpu
builder.append(m_decoded_input.substring(0, m_insertion_point.position));
builder.append(input);
builder.append(m_decoded_input.substring(m_insertion_point.position));
m_decoded_input = builder.build();
m_decoded_input = builder.to_deprecated_string();
m_utf8_view = Utf8View(m_decoded_input);
m_utf8_iterator = m_utf8_view.iterator_at_byte_offset(utf8_iterator_byte_offset);

View file

@ -284,7 +284,7 @@ JS::ThrowCompletionOr<size_t> WebAssemblyObject::instantiate_module(JS::VM& vm,
StringBuilder builder;
builder.append("LinkError: Missing "sv);
builder.join(' ', link_result.error().missing_imports);
return vm.throw_completion<JS::TypeError>(builder.build());
return vm.throw_completion<JS::TypeError>(builder.to_deprecated_string());
}
auto instance_result = s_abstract_machine.instantiate(module, link_result.release_value());