mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 17:58:26 -04:00
dev: Using built in rng.Shuffle, using some new .net types, removed some transactions
This commit is contained in:
@@ -267,20 +267,8 @@ public sealed partial class MusicQueue : IMusicQueue
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
var list = tracks.ToList();
|
||||
|
||||
for (var i = 0; i < list.Count; i++)
|
||||
{
|
||||
var struck = rng.Next(i, list.Count);
|
||||
(list[struck], list[i]) = (list[i], list[struck]);
|
||||
|
||||
// could preserving the index during shuffling be done better?
|
||||
if (i == index)
|
||||
index = struck;
|
||||
else if (struck == index)
|
||||
index = i;
|
||||
}
|
||||
|
||||
var list = tracks.ToArray();
|
||||
rng.Shuffle(list);
|
||||
tracks = new(list);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user