1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 14:02:55 +08:00
osu-lazer/osu.Game/Audio
Bartłomiej Dach 15d9147edd Ensure equality member consistency for SampleInfo
The previous implementation of `SampleInfo`'s equality members was not
completely correct in its treatment of the `sampleNames` array. While
`Equals()` compared the values of `sampleNames` using `SequenceEqual()`,
therefore performing a structural check that inspects the contents of
both arrays, `GetHashCode()` used `HashCode.Combine()` directly on the
arrays, therefore operating on reference equality. This could cause the
pooling mechanism of samples to fail, as pointed out in #11079.

To resolve, change the `GetHashCode()` implementation such that it also
considers the contents of the array rather than just the reference to
the array itself. This is achieved by leveraging
`StructuralEqualityComparer`.

Additionally, as a bonus, an array sort was added to the constructor of
`SampleInfo`. This is intended to be a "canonicalisation" processing
step for the array of sample names. Thanks to that sort, two instances
of `SampleInfo` that have the same sample names but permutated will also
turn out to be equal and have the same hash codes, given the
implementation of both equality members. This gives `SampleInfo`
set-like semantics.
2020-12-03 23:25:53 +01:00
..
HitSampleInfo.cs Rename parameters 2020-12-02 10:55:48 +09:00
IPreviewTrackOwner.cs Turn on warnings, resolve issues 2019-04-25 17:36:17 +09:00
ISampleInfo.cs Fix skinning support for combobreak 2019-06-30 21:58:30 +09:00
PreviewTrack.cs Private set on track for safety 2019-11-12 15:13:47 +09:00
PreviewTrackManager.cs Allow preview tracks to exist without an owner (without hard crashing) 2020-11-15 13:21:09 +09:00
SampleInfo.cs Ensure equality member consistency for SampleInfo 2020-12-03 23:25:53 +01:00