mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[ion/utf8_helper] Reuse strlen value
This commit is contained in:
committed by
EmilieNumworks
parent
f96e4e92ce
commit
e00cb91f74
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user