diff --git a/ext/native/util/text/wrap_text.cpp b/ext/native/util/text/wrap_text.cpp index c052056034..68ca6d7b5a 100644 --- a/ext/native/util/text/wrap_text.cpp +++ b/ext/native/util/text/wrap_text.cpp @@ -143,6 +143,10 @@ void WordWrapper::Wrap() { // First, let's check if it fits as-is. size_t len = strlen(str_); + + // We know it'll be approximately this size. It's fine if the guess is a little off. + out_.reserve(len + len / 16); + if (MeasureWidth(str_, len) <= maxW_) { // If it fits, we don't need to go through each character. out_ = str_;