From 16405583ceb0630862e9dc746d5224be8d2fd173 Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Fri, 29 Jun 2018 16:07:19 -0500 Subject: [PATCH] Avoid StringBuilder allocations --- libhac/Romfs.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libhac/Romfs.cs b/libhac/Romfs.cs index 111106e7..0359d970 100644 --- a/libhac/Romfs.cs +++ b/libhac/Romfs.cs @@ -104,19 +104,27 @@ namespace libhac private void ResolveFilenames() { + var list = new List(); var sb = new StringBuilder(); + var delimiter = "/"; foreach (var file in Files) { - sb.Append(file.Name); + list.Add(file.Name); var dir = file.ParentDir; while (dir != null) { - sb.Insert(0, "/"); - sb.Insert(0, dir.Name); + list.Add(delimiter); + list.Add(dir.Name); dir = dir.Parent; } + for (int i = list.Count-1; i >= 0; i--) + { + sb.Append(list[i]); + } + file.FullPath = sb.ToString(); + list.Clear(); sb.Clear(); } }