From ac2ab1bdcc967298cabb494ee6fa5bc6bbc953a4 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 25 Dec 2021 05:18:33 -0500 Subject: [PATCH] Only calculate string when we need it --- src/hu_stuff.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 059bc00f8..498daad9a 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -897,13 +897,7 @@ static inline boolean HU_keyInChatString(char *s, char ch) // static void HU_TickSongCredits(void) { - char *str; - INT32 len; - fixed_t destx; - - cursongcredit.old_x = cursongcredit.x; - - if (!cursongcredit.def) // No def + if (cursongcredit.def == NULL) // No def { cursongcredit.x = cursongcredit.old_x = 0; cursongcredit.anim = 0; @@ -911,12 +905,14 @@ static void HU_TickSongCredits(void) return; } - str = va("\x1F"" %s", cursongcredit.def->source); - len = V_ThinStringWidth(str, V_ALLOWLOWERCASE|V_6WIDTHSPACE); - destx = (len+7) * FRACUNIT; + cursongcredit.old_x = cursongcredit.x; if (cursongcredit.anim > 0) { + char *str = va("\x1F"" %s", cursongcredit.def->source); + INT32 len = V_ThinStringWidth(str, V_ALLOWLOWERCASE|V_6WIDTHSPACE); + fixed_t destx = (len+7) * FRACUNIT; + if (cursongcredit.trans > 0) { cursongcredit.trans--;