mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Avoid StringBuilder allocations
This commit is contained in:
parent
b6cac8b5f2
commit
16405583ce
1 changed files with 11 additions and 3 deletions
|
@ -104,19 +104,27 @@ namespace libhac
|
|||
|
||||
private void ResolveFilenames()
|
||||
{
|
||||
var list = new List<string>();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue