Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit f4e473f

Browse files
committed
Use StringBuilder for GetTransformPath
1 parent 8c5e767 commit f4e473f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Core/Utility/UnityHelpers.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,18 @@ public static bool IsNullOrDestroyed(this object obj, bool suppressWarning = tru
5656
/// </summary>
5757
public static string GetTransformPath(this Transform transform, bool includeSelf = false)
5858
{
59-
string path = includeSelf
60-
? transform.transform.name
61-
: "";
59+
var sb = new StringBuilder();
60+
if (includeSelf)
61+
sb.Append(transform.name);
6262

6363
while (transform.parent)
6464
{
6565
transform = transform.parent;
66-
path = $"{transform.name}/{path}";
66+
sb.Insert(0, '/');
67+
sb.Insert(0, transform.name);
6768
}
6869

69-
return path;
70+
return sb.ToString();
7071
}
7172

7273
/// <summary>

0 commit comments

Comments
 (0)