From e00cb91f74dd12a498bc96d7ce05d07971ee41ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Thu, 5 Nov 2020 11:58:27 +0100 Subject: [PATCH] [ion/utf8_helper] Reuse strlen value --- ion/src/shared/unicode/utf8_helper.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ion/src/shared/unicode/utf8_helper.cpp b/ion/src/shared/unicode/utf8_helper.cpp index 731268c3f..9393069a6 100644 --- a/ion/src/shared/unicode/utf8_helper.cpp +++ b/ion/src/shared/unicode/utf8_helper.cpp @@ -143,14 +143,14 @@ void RemoveCodePoint(char * buffer, CodePoint c, const char * * pointerToUpdate, } bool SlideStringByNumberOfChar(char * text, int slidingSize, size_t textMaxLength) { - size_t lenText = strlen(text); - if (lenText + slidingSize > textMaxLength || lenText + slidingSize < 0) { + const size_t textLen = strlen(text); + if (textLen + slidingSize > textMaxLength || textLen + slidingSize < 0) { return false; } if (slidingSize > 0) { - memmove(text+slidingSize, text, strlen(text)+1); + memmove(text+slidingSize, text, textLen + 1); } else if (slidingSize < 0) { - memmove(text, text-slidingSize, strlen(text)+1); + memmove(text, text-slidingSize, textLen + 1); } // In case slidingSize = 0, there is nothing to do return true;