MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / simplify

Method simplify

core/string/node_path.cpp:351–374  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

349}
350
351void NodePath::simplify() {
352 if (!data) {
353 return;
354 }
355 for (int i = 0; i < data->path.size(); i++) {
356 if (data->path.size() == 1) {
357 break;
358 }
359 if (data->path[i].operator String() == ".") {
360 data->path.remove_at(i);
361 i--;
362 } else if (i > 0 && data->path[i].operator String() == ".." && data->path[i - 1].operator String() != "." && data->path[i - 1].operator String() != "..") {
363 //remove both
364 data->path.remove_at(i - 1);
365 data->path.remove_at(i - 1);
366 i -= 2;
367 if (data->path.is_empty()) {
368 data->path.push_back(".");
369 break;
370 }
371 }
372 }
373 data->hash_cache_valid = false;
374}
375
376NodePath NodePath::simplified() const {
377 NodePath np = *this;

Callers 3

simplifiedMethod · 0.80
_pre_fix_nodeMethod · 0.80
_update_node_pathMethod · 0.80

Calls 5

sizeMethod · 0.65
StringMethod · 0.45
remove_atMethod · 0.45
is_emptyMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected