Minor optimization in wrap_text.cpp

This commit is contained in:
Henrik Rydgård 2020-09-22 21:12:45 +02:00
parent 4ccde48485
commit 437818aa45

View file

@ -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_;