From 45800b026feda679b9aa704834bd0c9ec384f758 Mon Sep 17 00:00:00 2001 From: Jack Del Vecchio Date: Wed, 30 Oct 2024 15:26:45 -0400 Subject: [PATCH] Remove duplicate code. --- system/jlib/jstring.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/system/jlib/jstring.cpp b/system/jlib/jstring.cpp index a99f695da10..047fa80ebc6 100644 --- a/system/jlib/jstring.cpp +++ b/system/jlib/jstring.cpp @@ -1071,17 +1071,10 @@ StringBuffer & StringBuffer::replaceString(const char* oldStr, const char* newSt { if (memcmp(buffer, oldStr, oldlen) == 0) { - if (newlen <= curLen) - { - memmove(buffer, newStr, newlen); - curLen = newlen; - } - else - { + if (newlen > curLen) ensureCapacity(newlen); - memcpy(buffer, newStr, newlen); - curLen = newlen; - } + memcpy(buffer, newStr, newlen); + curLen = newlen; } } else