From 28e9df7f476972ebe2673e4f3981575bc364aa03 Mon Sep 17 00:00:00 2001 From: Dav999-v Date: Mon, 20 Feb 2023 04:58:16 +0100 Subject: [PATCH] Move line width addition in next_wrap to be after switch block There is no overlap in side effects between this line and the switch statement after it, but it did result in adding the width of a final null terminator or newline to the width of the current line, which is a waste because those widths both 1) require trying to find non-existent characters in the font and 2) will not be used. I found this out because I added a debug print in find_glyphinfo(), and something was requesting lots of codepoint 0 from the font. --- desktop_version/src/Font.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/desktop_version/src/Font.cpp b/desktop_version/src/Font.cpp index 562ab506..f27c9f67 100644 --- a/desktop_version/src/Font.cpp +++ b/desktop_version/src/Font.cpp @@ -798,8 +798,6 @@ static bool next_wrap( goto next; } - linewidth += get_advance(f, str[idx]); - switch (str[idx]) { case ' ': @@ -817,6 +815,8 @@ static bool next_wrap( return true; } + linewidth += get_advance(f, str[idx]); + if (linewidth > maxwidth) { if (lenfromlastspace != 0)