Skip to content

Commit d16413a

Browse files
committed
Optimize NodePath to String by using cahced path
1 parent ee87ee8 commit d16413a

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

core/string/node_path.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ void NodePath::_update_hash_cache() const {
5252
void NodePath::prepend_period() {
5353
if (data->path.size() && data->path[0].operator String() != ".") {
5454
data->path.insert(0, ".");
55+
data->concatenated_path = StringName();
5556
data->hash_cache_valid = false;
5657
}
5758
}
@@ -179,15 +180,11 @@ NodePath::operator String() const {
179180
ret = "/";
180181
}
181182

182-
for (int i = 0; i < data->path.size(); i++) {
183-
if (i > 0) {
184-
ret += "/";
185-
}
186-
ret += data->path[i].operator String();
187-
}
183+
ret += get_concatenated_names();
188184

189-
for (int i = 0; i < data->subpath.size(); i++) {
190-
ret += ":" + data->subpath[i].operator String();
185+
String subpath = get_concatenated_subnames();
186+
if (!subpath.is_empty()) {
187+
ret += ":" + subpath;
191188
}
192189

193190
return ret;
@@ -356,6 +353,7 @@ void NodePath::simplify() {
356353
}
357354
}
358355
}
356+
data->concatenated_path = StringName();
359357
data->hash_cache_valid = false;
360358
}
361359

0 commit comments

Comments
 (0)