Skip to content

Commit

Permalink
Merge pull request #6386 from smoogipoo/localisable-string-nrt
Browse files Browse the repository at this point in the history
Enable NRT in `LocalisableStringEqualityComparer`
  • Loading branch information
bdach authored Oct 11, 2024
2 parents 857116f + a9d6738 commit db96651
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions osu.Framework.Tests/Localisation/LocalisableStringTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public void TestNullEqualsNull()
public void TestLocalisableStringDoesNotEqualNull()
{
testEquals(false, new LocalisableString(), new RomanisableString(makeStringA, makeStringB));
testEquals(false, new RomanisableString(makeStringA, makeStringB), new LocalisableString());
}

[Test]
Expand Down
14 changes: 6 additions & 8 deletions osu.Framework/Localisation/LocalisableStringEqualityComparer.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using System;
using System.Collections.Generic;

Expand All @@ -17,14 +15,14 @@ public class LocalisableStringEqualityComparer : IEqualityComparer<LocalisableSt

public bool Equals(LocalisableString x, LocalisableString y)
{
object xData = x.Data;
object yData = y.Data;

if (ReferenceEquals(null, xData) != ReferenceEquals(null, yData))
return false;
object? xData = x.Data;
object? yData = y.Data;

if (ReferenceEquals(null, xData))
return true;
return ReferenceEquals(null, yData);

if (ReferenceEquals(null, yData))
return false;

if (xData.GetType() != yData.GetType())
return EqualityComparer<object>.Default.Equals(xData, yData);
Expand Down

0 comments on commit db96651

Please sign in to comment.