Skip to content

Commit

Permalink
optimize a method in BreakModelApartCommand
Browse files Browse the repository at this point in the history
Previously, the method continued iterating even after a valid children was found

This simple change makes it stop as soon as the first valid child is found
  • Loading branch information
eeropomell committed Dec 1, 2024
1 parent 547affb commit ef18b58
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions Assets/Scripts/Commands/BreakModelApartCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,11 @@ bool isValid(Transform node)
bool hasValidDirectChildren(Transform node)
{
if (node.gameObject.activeInHierarchy == false) return false;
int count = 0;
foreach (Transform child in node)
{
if (!isValid(child)) continue;
count++;
if (isValid(child)) return true;
}
return count > 0;
return false;
}

bool isSubPath(string basePath, string potentialSubPath)
Expand Down

0 comments on commit ef18b58

Please sign in to comment.