From 884cbb5333120815fdc30ae2d33d66f99e817a53 Mon Sep 17 00:00:00 2001 From: Lukas Tenbrink Date: Thu, 28 Nov 2024 01:55:48 +0100 Subject: [PATCH] Don't repeat calls to strlen in split, and make splitter_length const in get_slice. --- core/string/ustring.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 9e99fc3b2f5..0e553a5680b 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -1278,7 +1278,7 @@ String String::get_slice(const char *p_splitter, int p_slice) const { } int i = 0; - int splitter_length = strlen(p_splitter); + const int splitter_length = strlen(p_splitter); while (true) { pos = find(p_splitter, pos); if (pos == -1) { @@ -1429,6 +1429,7 @@ Vector String::split(const char *p_splitter, bool p_allow_empty, int p_m int from = 0; int len = length(); + const int splitter_length = strlen(p_splitter); while (true) { int end; @@ -1459,7 +1460,7 @@ Vector String::split(const char *p_splitter, bool p_allow_empty, int p_m break; } - from = end + strlen(p_splitter); + from = end + splitter_length; } return ret;