From ef18b58bb3f2853473d95c9c52346685281f45e5 Mon Sep 17 00:00:00 2001 From: eeropomell Date: Sun, 1 Dec 2024 20:22:02 +0200 Subject: [PATCH] optimize a method in BreakModelApartCommand 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 --- Assets/Scripts/Commands/BreakModelApartCommand.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/Commands/BreakModelApartCommand.cs b/Assets/Scripts/Commands/BreakModelApartCommand.cs index e0745abc45..0ee683fde4 100644 --- a/Assets/Scripts/Commands/BreakModelApartCommand.cs +++ b/Assets/Scripts/Commands/BreakModelApartCommand.cs @@ -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)