You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Optimize NodePath to String by using cahced path
This commit is contained in:
@@ -52,6 +52,7 @@ void NodePath::_update_hash_cache() const {
|
|||||||
void NodePath::prepend_period() {
|
void NodePath::prepend_period() {
|
||||||
if (data->path.size() && data->path[0].operator String() != ".") {
|
if (data->path.size() && data->path[0].operator String() != ".") {
|
||||||
data->path.insert(0, ".");
|
data->path.insert(0, ".");
|
||||||
|
data->concatenated_path = StringName();
|
||||||
data->hash_cache_valid = false;
|
data->hash_cache_valid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,15 +180,11 @@ NodePath::operator String() const {
|
|||||||
ret = "/";
|
ret = "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < data->path.size(); i++) {
|
ret += get_concatenated_names();
|
||||||
if (i > 0) {
|
|
||||||
ret += "/";
|
|
||||||
}
|
|
||||||
ret += data->path[i].operator String();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < data->subpath.size(); i++) {
|
String subpath = get_concatenated_subnames();
|
||||||
ret += ":" + data->subpath[i].operator String();
|
if (!subpath.is_empty()) {
|
||||||
|
ret += ":" + subpath;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -356,6 +353,7 @@ void NodePath::simplify() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
data->concatenated_path = StringName();
|
||||||
data->hash_cache_valid = false;
|
data->hash_cache_valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user