colgreen / Redzen

General purpose C# code library.
Other
94 stars 16 forks source link

EnumerableUtils.RangeRandomOrder performance improvement #2

Closed ShadowGlass0 closed 6 years ago

ShadowGlass0 commented 6 years ago

A small performance improvement to the above: There's no need to store the returned value back into the array. That value will not be used again:

                   arr[swapIdx] = arr[i];
 -                 arr[i] = tmp;

 -                 yield return arr[i];
 +                 yield return tmp;
               }
colgreen commented 6 years ago

Thanks for this. I have made the change and it will be in a nuget release shortly.