1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:47:44 +00:00

AK: Ensure StringBuilder capacity in String::reverse

This commit is contained in:
Idan Horowitz 2021-06-29 17:50:37 +03:00 committed by Linus Groh
parent 4a2a084789
commit a768131720

View file

@ -358,7 +358,7 @@ size_t String::count(const String& needle) const
String String::reverse() const String String::reverse() const
{ {
StringBuilder reversed_string; StringBuilder reversed_string(length());
for (size_t i = length(); i-- > 0;) { for (size_t i = length(); i-- > 0;) {
reversed_string.append(characters()[i]); reversed_string.append(characters()[i]);
} }