mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Clean up some uses of String::substr
Cases where the end position is either equvalent to the default or past the end of the string.
This commit is contained in:
parent
f2cc3f1275
commit
5113022dfe
54 changed files with 123 additions and 123 deletions
|
@ -1096,7 +1096,7 @@ bool ShaderPreprocessor::expand_macros_once(const String &p_line, int p_line_num
|
|||
int arg_index_start = 0;
|
||||
int arg_index = 0;
|
||||
while (find_match(body, arg_name, arg_index, arg_index_start)) {
|
||||
body = body.substr(0, arg_index) + args[i] + body.substr(arg_index + arg_name.length(), body.length() - (arg_index + arg_name.length()));
|
||||
body = body.substr(0, arg_index) + args[i] + body.substr(arg_index + arg_name.length());
|
||||
// Manually reset arg_index_start to where the arg value of the define finishes.
|
||||
// This ensures we don't skip the other args of this macro in the string.
|
||||
arg_index_start = arg_index + args[i].length() + 1;
|
||||
|
@ -1105,11 +1105,11 @@ bool ShaderPreprocessor::expand_macros_once(const String &p_line, int p_line_num
|
|||
|
||||
concatenate_macro_body(body);
|
||||
|
||||
result = result.substr(0, index) + " " + body + " " + result.substr(args_end + 1, result.length());
|
||||
result = result.substr(0, index) + " " + body + " " + result.substr(args_end + 1);
|
||||
} else {
|
||||
concatenate_macro_body(body);
|
||||
|
||||
result = result.substr(0, index) + " " + body + " " + result.substr(index + key.length(), result.length() - (index + key.length()));
|
||||
result = result.substr(0, index) + " " + body + " " + result.substr(index + key.length());
|
||||
}
|
||||
|
||||
r_expanded = result;
|
||||
|
@ -1176,7 +1176,7 @@ void ShaderPreprocessor::concatenate_macro_body(String &r_body) {
|
|||
index_start--;
|
||||
}
|
||||
|
||||
r_body = r_body.substr(0, index_start) + r_body.substr(index_end, r_body.length() - index_end);
|
||||
r_body = r_body.substr(0, index_start) + r_body.substr(index_end);
|
||||
|
||||
index_start = r_body.find("##", index_start);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue