Skip to content

Commit 6e74593

Browse files
committed
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.
1 parent da81041 commit 6e74593

File tree

129 files changed

+213
-219
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+213
-219
lines changed

AK/DeprecatedString.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class DeprecatedString {
106106
{
107107
StringBuilder builder;
108108
builder.join(separator, collection, fmtstr);
109-
return builder.build();
109+
return builder.to_deprecated_string();
110110
}
111111

112112
[[nodiscard]] bool matches(StringView mask, CaseSensitivity = CaseSensitivity::CaseInsensitive) const;

AK/Hex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ DeprecatedString encode_hex(const ReadonlyBytes input)
5252
for (auto ch : input)
5353
output.appendff("{:02x}", ch);
5454

55-
return output.build();
55+
return output.to_deprecated_string();
5656
}
5757
#endif
5858

AK/JsonArray.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ inline typename Builder::OutputType JsonArray::serialized() const
109109
{
110110
Builder builder;
111111
serialize(builder);
112-
return builder.build();
112+
return builder.to_deprecated_string();
113113
}
114114

115115
}

AK/JsonObject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ inline typename Builder::OutputType JsonObject::serialized() const
139139
{
140140
Builder builder;
141141
serialize(builder);
142-
return builder.build();
142+
return builder.to_deprecated_string();
143143
}
144144

145145
template<typename Builder>
@@ -190,7 +190,7 @@ inline typename Builder::OutputType JsonValue::serialized() const
190190
{
191191
Builder builder;
192192
serialize(builder);
193-
return builder.build();
193+
return builder.to_deprecated_string();
194194
}
195195

196196
}

AK/SourceGenerator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class SourceGenerator {
5757
}
5858

5959
StringView as_string_view() const { return m_builder.string_view(); }
60-
DeprecatedString as_string() const { return m_builder.build(); }
60+
DeprecatedString as_string() const { return m_builder.to_deprecated_string(); }
6161

6262
void append(StringView pattern)
6363
{

AK/StringBuilder.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,6 @@ DeprecatedString StringBuilder::to_deprecated_string() const
118118
return DeprecatedString((char const*)data(), length());
119119
}
120120

121-
DeprecatedString StringBuilder::build() const
122-
{
123-
return to_deprecated_string();
124-
}
125-
126121
ErrorOr<String> StringBuilder::to_string() const
127122
{
128123
return String::from_utf8(string_view());

AK/StringBuilder.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ class StringBuilder {
6262
}
6363

6464
#ifndef KERNEL
65-
[[nodiscard]] DeprecatedString build() const;
6665
[[nodiscard]] DeprecatedString to_deprecated_string() const;
6766
ErrorOr<String> to_string() const;
6867
#endif

AK/StringUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ DeprecatedString replace(StringView str, StringView needle, StringView replaceme
546546
last_position = position + needle.length();
547547
}
548548
replaced_string.append(str.substring_view(last_position, str.length() - last_position));
549-
return replaced_string.build();
549+
return replaced_string.to_deprecated_string();
550550
}
551551

552552
ErrorOr<String> replace(String const& haystack, StringView needle, StringView replacement, ReplaceMode replace_mode)

AK/URL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ DeprecatedString URL::serialize_origin() const
348348
builder.append(m_host);
349349
if (m_port.has_value())
350350
builder.appendff(":{}", *m_port);
351-
return builder.build();
351+
return builder.to_deprecated_string();
352352
}
353353

354354
bool URL::equals(URL const& other, ExcludeFragment exclude_fragments) const

Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ public:)~~~");
371371
builder.append(", "sv);
372372
}
373373

374-
message_generator.set("message.constructor_call_parameters", builder.build());
374+
message_generator.set("message.constructor_call_parameters", builder.to_deprecated_string());
375375
message_generator.appendln(R"~~~(
376376
return make<@message.pascal_name@>(@message.constructor_call_parameters@);
377377
})~~~");

0 commit comments

Comments
 (0)