mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 09:23:06 +08:00
Use GroupBy() instead
This commit is contained in:
parent
bb0d289993
commit
dee46d7ba2
@ -421,13 +421,11 @@ namespace osu.Game
|
|||||||
|
|
||||||
public virtual async Task Import(params ImportTask[] tasks)
|
public virtual async Task Import(params ImportTask[] tasks)
|
||||||
{
|
{
|
||||||
var extensions = tasks.Select(t => Path.GetExtension(t.Path).ToLowerInvariant()).Distinct();
|
var tasksPerExtension = tasks.GroupBy(t => Path.GetExtension(t.Path).ToLowerInvariant());
|
||||||
await Task.WhenAll(extensions.Select(ext =>
|
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(taskGroup.Key));
|
||||||
|
return importer?.Import(taskGroup.ToArray()) ?? Task.CompletedTask;
|
||||||
var importer = fileImporters.FirstOrDefault(i => i.HandledExtensions.Contains(ext));
|
|
||||||
return importer?.Import(imports.ToArray()) ?? Task.CompletedTask;
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user