Skip to content

Commit f787aec

Browse files
committed
Minor
1 parent 5f72118 commit f787aec

File tree

4 files changed

+16
-27
lines changed

4 files changed

+16
-27
lines changed

JL.Core/Dicts/JMdict/JmdictRecord.cs

+5-8
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,11 @@ public int GetFrequency(Dictionary<string, List<FrequencyRecord>> freqDict)
371371
return int.MaxValue;
372372
}
373373

374+
public override int GetHashCode()
375+
{
376+
return HashCode.Combine(Id, PrimarySpelling.GetHashCode(StringComparison.Ordinal));
377+
}
378+
374379
public override bool Equals(object? obj)
375380
{
376381
return obj is JmdictRecord jmdictRecord
@@ -385,14 +390,6 @@ public bool Equals(JmdictRecord? other)
385390
&& PrimarySpelling == other.PrimarySpelling;
386391
}
387392

388-
public override int GetHashCode()
389-
{
390-
unchecked
391-
{
392-
return Id * PrimarySpelling.GetHashCode(StringComparison.Ordinal);
393-
}
394-
}
395-
396393
public static bool operator ==(JmdictRecord? left, JmdictRecord? right) => left?.Equals(right) ?? right is null;
397394
public static bool operator !=(JmdictRecord? left, JmdictRecord? right) => !left?.Equals(right) ?? right is not null;
398395
}

JL.Core/Dicts/JMnedict/JmnedictRecord.cs

+5-8
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ public string BuildFormattedDefinition(DictOptions options)
7171
return defResult.ToString();
7272
}
7373

74+
public override int GetHashCode()
75+
{
76+
return HashCode.Combine(Id, PrimarySpelling.GetHashCode(StringComparison.Ordinal));
77+
}
78+
7479
public override bool Equals(object? obj)
7580
{
7681
return obj is JmnedictRecord jmnedictObj
@@ -85,14 +90,6 @@ public bool Equals(JmnedictRecord? other)
8590
&& PrimarySpelling == other.PrimarySpelling;
8691
}
8792

88-
public override int GetHashCode()
89-
{
90-
unchecked
91-
{
92-
return Id * PrimarySpelling.GetHashCode(StringComparison.Ordinal);
93-
}
94-
}
95-
9693
public static bool operator ==(JmnedictRecord? left, JmnedictRecord? right) => left?.Equals(right) ?? right is null;
9794
public static bool operator !=(JmnedictRecord? left, JmnedictRecord? right) => !left?.Equals(right) ?? right is not null;
9895
}

JL.Core/Dicts/PitchAccent/PitchAccentRecord.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ public PitchAccentRecord(List<JsonElement> jsonElements)
5454
: Reading!.GetPooledString();
5555
}
5656

57+
public override int GetHashCode()
58+
{
59+
return HashCode.Combine(Spelling.GetHashCode(StringComparison.Ordinal), Reading?.GetHashCode(StringComparison.Ordinal) ?? 0);
60+
}
61+
5762
public override bool Equals(object? obj)
5863
{
5964
return obj is PitchAccentRecord pitchAccentRecord
@@ -68,11 +73,6 @@ public bool Equals(PitchAccentRecord? other)
6873
&& Reading == other.Reading;
6974
}
7075

71-
public override int GetHashCode()
72-
{
73-
return HashCode.Combine(Spelling, Reading);
74-
}
75-
7676
public static bool operator ==(PitchAccentRecord? left, PitchAccentRecord? right) => left?.Equals(right) ?? right is null;
7777
public static bool operator !=(PitchAccentRecord? left, PitchAccentRecord? right) => !left?.Equals(right) ?? right is not null;
7878
}

JL.Windows/WinApi.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,7 @@ internal struct LPPOINT : IEquatable<LPPOINT>
4242

4343
public override readonly int GetHashCode()
4444
{
45-
unchecked
46-
{
47-
int hash = (17 * 37) + X;
48-
hash = (hash * 37) + Y;
49-
return hash;
50-
}
45+
return HashCode.Combine(X, Y);
5146
}
5247

5348
public override readonly bool Equals(object? obj)

0 commit comments

Comments
 (0)