From 70be8f4d94acd0edca9cdd6802339a50204f75c8 Mon Sep 17 00:00:00 2001 From: Stefan Wurzinger Date: Mon, 22 Oct 2018 02:25:45 +0200 Subject: [PATCH] improve song enumeration performance --- Vocaluxe/Base/CSongs.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Vocaluxe/Base/CSongs.cs b/Vocaluxe/Base/CSongs.cs index d3670c80..555fe93e 100644 --- a/Vocaluxe/Base/CSongs.cs +++ b/Vocaluxe/Base/CSongs.cs @@ -339,18 +339,17 @@ namespace Vocaluxe.Base SongsLoaded = false; _Songs.Clear(); - var files = new List(); + var files = Enumerable.Empty(); using (CBenchmark.Time("List Songs")) { - foreach (string p in CConfig.SongFolders) + foreach (string path in CConfig.SongFolders) { - if (Directory.Exists(p)) + if (Directory.Exists(path)) { - string path = p; - files.AddRange(CHelper.ListFiles(path, "*.txt", true, true)); - files.AddRange(CHelper.ListFiles(path, "*.txd", true, true)); + files = files.Union(Directory.EnumerateFiles(path, "*.txt", SearchOption.AllDirectories)); + files = files.Union(Directory.EnumerateFiles(path, "*.txd", SearchOption.AllDirectories)); } } }