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()
|
private void ResolveFilenames()
|
||||||
{
|
{
|
||||||
|
var list = new List<string>();
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
|
var delimiter = "/";
|
||||||
foreach (var file in Files)
|
foreach (var file in Files)
|
||||||
{
|
{
|
||||||
sb.Append(file.Name);
|
list.Add(file.Name);
|
||||||
var dir = file.ParentDir;
|
var dir = file.ParentDir;
|
||||||
while (dir != null)
|
while (dir != null)
|
||||||
{
|
{
|
||||||
sb.Insert(0, "/");
|
list.Add(delimiter);
|
||||||
sb.Insert(0, dir.Name);
|
list.Add(dir.Name);
|
||||||
dir = dir.Parent;
|
dir = dir.Parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = list.Count-1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
sb.Append(list[i]);
|
||||||
|
}
|
||||||
|
|
||||||
file.FullPath = sb.ToString();
|
file.FullPath = sb.ToString();
|
||||||
|
list.Clear();
|
||||||
sb.Clear();
|
sb.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue