mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Don't repeat calls to strlen in split, and make splitter_length const in get_slice.
This commit is contained in:
parent
f128f383e8
commit
884cbb5333
1 changed files with 3 additions and 2 deletions
|
@ -1278,7 +1278,7 @@ String String::get_slice(const char *p_splitter, int p_slice) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int splitter_length = strlen(p_splitter);
|
const int splitter_length = strlen(p_splitter);
|
||||||
while (true) {
|
while (true) {
|
||||||
pos = find(p_splitter, pos);
|
pos = find(p_splitter, pos);
|
||||||
if (pos == -1) {
|
if (pos == -1) {
|
||||||
|
@ -1429,6 +1429,7 @@ Vector<String> String::split(const char *p_splitter, bool p_allow_empty, int p_m
|
||||||
|
|
||||||
int from = 0;
|
int from = 0;
|
||||||
int len = length();
|
int len = length();
|
||||||
|
const int splitter_length = strlen(p_splitter);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
int end;
|
int end;
|
||||||
|
@ -1459,7 +1460,7 @@ Vector<String> String::split(const char *p_splitter, bool p_allow_empty, int p_m
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
from = end + strlen(p_splitter);
|
from = end + splitter_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue