1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 02:32:55 +08:00

Use GroupBy() instead

This commit is contained in:
Bartłomiej Dach 2021-01-16 23:42:28 +01:00
parent bb0d289993
commit dee46d7ba2

View File

@ -421,13 +421,11 @@ namespace osu.Game
public virtual async Task Import(params ImportTask[] tasks)
{
var extensions = tasks.Select(t => Path.GetExtension(t.Path).ToLowerInvariant()).Distinct();
await Task.WhenAll(extensions.Select(ext =>
var tasksPerExtension = tasks.GroupBy(t => Path.GetExtension(t.Path).ToLowerInvariant());
await Task.WhenAll(tasksPerExtension.Select(taskGroup =>
{
var imports = tasks.Where(t => t.Path.EndsWith(ext, StringComparison.OrdinalIgnoreCase));
var importer = fileImporters.FirstOrDefault(i => i.HandledExtensions.Contains(ext));
return importer?.Import(imports.ToArray()) ?? Task.CompletedTask;
var importer = fileImporters.FirstOrDefault(i => i.HandledExtensions.Contains(taskGroup.Key));
return importer?.Import(taskGroup.ToArray()) ?? Task.CompletedTask;
}));
}