1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 20:13:22 +08:00

Convert == usages to ReferenceEquals

This commit is contained in:
Dan Balasescu 2022-06-20 16:53:03 +09:00
parent 16281f4a48
commit e0c82d11ab
12 changed files with 20 additions and 19 deletions

View File

@ -374,7 +374,7 @@ namespace osu.Game.Rulesets.Osu.Mods
int i = 0; int i = 0;
double currentTime = timingPoint.Time; double currentTime = timingPoint.Time;
while (!definitelyBigger(currentTime, mapEndTime) && controlPointInfo.TimingPointAt(currentTime) == timingPoint) while (!definitelyBigger(currentTime, mapEndTime) && ReferenceEquals(controlPointInfo.TimingPointAt(currentTime), timingPoint))
{ {
beats.Add(Math.Floor(currentTime)); beats.Add(Math.Floor(currentTime));
i++; i++;

View File

@ -117,8 +117,8 @@ namespace osu.Game.Tests.Visual.Editing
// After placement these must be non-default as defaults are read-only. // After placement these must be non-default as defaults are read-only.
AddAssert("Placed object has non-default control points", () => AddAssert("Placed object has non-default control points", () =>
EditorBeatmap.HitObjects[0].SampleControlPoint != SampleControlPoint.DEFAULT && !ReferenceEquals(EditorBeatmap.HitObjects[0].SampleControlPoint, SampleControlPoint.DEFAULT) &&
EditorBeatmap.HitObjects[0].DifficultyControlPoint != DifficultyControlPoint.DEFAULT); !ReferenceEquals(EditorBeatmap.HitObjects[0].DifficultyControlPoint, DifficultyControlPoint.DEFAULT));
ReloadEditorToSameBeatmap(); ReloadEditorToSameBeatmap();
@ -126,8 +126,8 @@ namespace osu.Game.Tests.Visual.Editing
// After placement these must be non-default as defaults are read-only. // After placement these must be non-default as defaults are read-only.
AddAssert("Placed object still has non-default control points", () => AddAssert("Placed object still has non-default control points", () =>
EditorBeatmap.HitObjects[0].SampleControlPoint != SampleControlPoint.DEFAULT && !ReferenceEquals(EditorBeatmap.HitObjects[0].SampleControlPoint, SampleControlPoint.DEFAULT) &&
EditorBeatmap.HitObjects[0].DifficultyControlPoint != DifficultyControlPoint.DEFAULT); !ReferenceEquals(EditorBeatmap.HitObjects[0].DifficultyControlPoint, DifficultyControlPoint.DEFAULT));
} }
[Test] [Test]

View File

@ -269,7 +269,7 @@ namespace osu.Game.Tests.Visual.UserInterface
private TimingControlPoint getNextTimingPoint(TimingControlPoint current) private TimingControlPoint getNextTimingPoint(TimingControlPoint current)
{ {
if (timingPoints[^1] == current) if (ReferenceEquals(timingPoints[^1], current))
return current; return current;
int index = timingPoints.IndexOf(current); // -1 means that this is a "default beat" int index = timingPoints.IndexOf(current); // -1 means that this is a "default beat"
@ -281,7 +281,7 @@ namespace osu.Game.Tests.Visual.UserInterface
{ {
if (timingPoints.Count == 0) return 0; if (timingPoints.Count == 0) return 0;
if (timingPoints[^1] == current) if (ReferenceEquals(timingPoints[^1], current))
{ {
Debug.Assert(BeatSyncSource.Clock != null); Debug.Assert(BeatSyncSource.Clock != null);

View File

@ -127,7 +127,7 @@ namespace osu.Game.Graphics.Containers
TimeSinceLastBeat = beatLength - TimeUntilNextBeat; TimeSinceLastBeat = beatLength - TimeUntilNextBeat;
if (timingPoint == lastTimingPoint && beatIndex == lastBeat) if (ReferenceEquals(timingPoint, lastTimingPoint) && beatIndex == lastBeat)
return; return;
// as this event is sometimes used for sound triggers where `BeginDelayedSequence` has no effect, avoid firing it if too far away from the beat. // as this event is sometimes used for sound triggers where `BeginDelayedSequence` has no effect, avoid firing it if too far away from the beat.

View File

@ -108,7 +108,7 @@ namespace osu.Game.Rulesets.Objects
if (legacyInfo != null) if (legacyInfo != null)
DifficultyControlPoint = (DifficultyControlPoint)legacyInfo.DifficultyPointAt(StartTime).DeepClone(); DifficultyControlPoint = (DifficultyControlPoint)legacyInfo.DifficultyPointAt(StartTime).DeepClone();
else if (DifficultyControlPoint == DifficultyControlPoint.DEFAULT) else if (ReferenceEquals(DifficultyControlPoint, DifficultyControlPoint.DEFAULT))
DifficultyControlPoint = new DifficultyControlPoint(); DifficultyControlPoint = new DifficultyControlPoint();
DifficultyControlPoint.Time = StartTime; DifficultyControlPoint.Time = StartTime;
@ -118,7 +118,7 @@ namespace osu.Game.Rulesets.Objects
// This is done here after ApplyDefaultsToSelf as we may require custom defaults to be applied to have an accurate end time. // This is done here after ApplyDefaultsToSelf as we may require custom defaults to be applied to have an accurate end time.
if (legacyInfo != null) if (legacyInfo != null)
SampleControlPoint = (SampleControlPoint)legacyInfo.SamplePointAt(this.GetEndTime() + control_point_leniency).DeepClone(); SampleControlPoint = (SampleControlPoint)legacyInfo.SamplePointAt(this.GetEndTime() + control_point_leniency).DeepClone();
else if (SampleControlPoint == SampleControlPoint.DEFAULT) else if (ReferenceEquals(SampleControlPoint, SampleControlPoint.DEFAULT))
SampleControlPoint = new SampleControlPoint(); SampleControlPoint = new SampleControlPoint();
SampleControlPoint.Time = this.GetEndTime() + control_point_leniency; SampleControlPoint.Time = this.GetEndTime() + control_point_leniency;

View File

@ -49,7 +49,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
case NotifyCollectionChangedAction.Remove: case NotifyCollectionChangedAction.Remove:
foreach (var group in args.OldItems.OfType<ControlPointGroup>()) foreach (var group in args.OldItems.OfType<ControlPointGroup>())
{ {
var matching = Children.SingleOrDefault(gv => gv.Group == group); var matching = Children.SingleOrDefault(gv => ReferenceEquals(gv.Group, group));
if (matching != null) if (matching != null)
matching.Expire(); matching.Expire();

View File

@ -40,7 +40,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
case NotifyCollectionChangedAction.Remove: case NotifyCollectionChangedAction.Remove:
foreach (var group in args.OldItems.OfType<ControlPointGroup>()) foreach (var group in args.OldItems.OfType<ControlPointGroup>())
{ {
var matching = Children.SingleOrDefault(gv => gv.Group == group); var matching = Children.SingleOrDefault(gv => ReferenceEquals(gv.Group, group));
matching?.Expire(); matching?.Expire();
} }

View File

@ -205,7 +205,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
updateRepeats(repeats); updateRepeats(repeats);
} }
if (difficultyControlPoint != Item.DifficultyControlPoint) if (!ReferenceEquals(difficultyControlPoint, Item.DifficultyControlPoint))
{ {
difficultyControlPoint = Item.DifficultyControlPoint; difficultyControlPoint = Item.DifficultyControlPoint;
difficultyOverrideDisplay?.Expire(); difficultyOverrideDisplay?.Expire();
@ -220,7 +220,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
} }
} }
if (sampleControlPoint != Item.SampleControlPoint) if (!ReferenceEquals(sampleControlPoint, Item.SampleControlPoint))
{ {
sampleControlPoint = Item.SampleControlPoint; sampleControlPoint = Item.SampleControlPoint;
sampleOverrideDisplay?.Expire(); sampleOverrideDisplay?.Expire();
@ -393,7 +393,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
if (e.CurrentState.Keyboard.ShiftPressed) if (e.CurrentState.Keyboard.ShiftPressed)
{ {
if (hitObject.DifficultyControlPoint == DifficultyControlPoint.DEFAULT) if (ReferenceEquals(hitObject.DifficultyControlPoint, DifficultyControlPoint.DEFAULT))
hitObject.DifficultyControlPoint = new DifficultyControlPoint(); hitObject.DifficultyControlPoint = new DifficultyControlPoint();
double newVelocity = hitObject.DifficultyControlPoint.SliderVelocity * (repeatHitObject.Duration / proposedDuration); double newVelocity = hitObject.DifficultyControlPoint.SliderVelocity * (repeatHitObject.Duration / proposedDuration);

View File

@ -141,7 +141,7 @@ namespace osu.Game.Screens.Edit
seekTime = timingPoint.Time + closestBeat * seekAmount; seekTime = timingPoint.Time + closestBeat * seekAmount;
} }
if (seekTime < timingPoint.Time && timingPoint != ControlPointInfo.TimingPoints.First()) if (seekTime < timingPoint.Time && !ReferenceEquals(timingPoint, ControlPointInfo.TimingPoints.First()))
seekTime = timingPoint.Time; seekTime = timingPoint.Time;
SeekSmoothlyTo(seekTime); SeekSmoothlyTo(seekTime);

View File

@ -65,7 +65,8 @@ namespace osu.Game.Screens.Edit.Timing
selectedGroup.BindValueChanged(group => selectedGroup.BindValueChanged(group =>
{ {
// TODO: This should scroll the selected row into view. // TODO: This should scroll the selected row into view.
foreach (var b in BackgroundFlow) b.Selected = b.Item == group.NewValue; foreach (var b in BackgroundFlow)
b.Selected = ReferenceEquals(b.Item, group.NewValue);
}, true); }, true);
} }

View File

@ -222,7 +222,7 @@ namespace osu.Game.Screens.Edit.Timing
// Try and create matching types from the currently selected control point. // Try and create matching types from the currently selected control point.
var selected = selectedGroup.Value; var selected = selectedGroup.Value;
if (selected != null && selected != group) if (selected != null && !ReferenceEquals(selected, group))
{ {
foreach (var controlPoint in selected.ControlPoints) foreach (var controlPoint in selected.ControlPoints)
{ {

View File

@ -128,7 +128,7 @@ namespace osu.Game.Screens.Edit.Timing
double? offsetChange = newStartTime - selectedGroupStartTime; double? offsetChange = newStartTime - selectedGroupStartTime;
var nextGroup = editorBeatmap.ControlPointInfo.TimingPoints var nextGroup = editorBeatmap.ControlPointInfo.TimingPoints
.SkipWhile(g => g != tcp) .SkipWhile(g => !ReferenceEquals(g, tcp))
.Skip(1) .Skip(1)
.FirstOrDefault(); .FirstOrDefault();