Skip to content

Commit

Permalink
Re-parallelize UnspecifiedSearch
Browse files Browse the repository at this point in the history
  • Loading branch information
sonicfind committed Oct 6, 2024
1 parent 18817df commit 27bc55e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Assets/Script/Song/SongSearching.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using YARG.Core;
using YARG.Core.Logging;
using YARG.Core.Song;
Expand Down Expand Up @@ -451,17 +452,20 @@ private static int GetIndex(string songStr, string argument)
private static SongEntry[] UnspecifiedSearch(FilterNode filter, List<SongEntry> songs)
{
var nodes = new List<UnspecifiedSortNode>(songs.Count);
for (int i = 0; i < songs.Count; ++i)
Parallel.ForEach(songs, song =>
{
var node = new UnspecifiedSortNode(songs[i], filter);
var node = new UnspecifiedSortNode(song, filter);
if (node.Rank >= 0)
{
nodes.Insert(~nodes.BinarySearch(node), node);
lock (nodes)
{
nodes.Insert(~nodes.BinarySearch(node), node);
}
}
}
});

var arr = new SongEntry[nodes.Count];
for (int i = 0; i < arr.Length; ++i)
for (int i = 0; i < nodes.Count; ++i)
{
arr[i] = nodes[i].Song;
}
Expand Down

0 comments on commit 27bc55e

Please sign in to comment.