@@ -1800,18 +1800,23 @@ public override bool Equals(object? obj)
1800
1800
/// <returns></returns>
1801
1801
public override int GetHashCode ( )
1802
1802
{
1803
- const int PRIME = 31 ; // arbitrary prime
1804
- int hash = PRIME ;
1805
- using ( var iter = GetEnumerator ( ) )
1803
+ unchecked
1806
1804
{
1807
- while ( iter . MoveNext ( ) )
1805
+ const int PRIME = 31 ; // arbitrary prime
1806
+ int hash = PRIME ;
1807
+ using ( var iter = GetEnumerator ( ) )
1808
1808
{
1809
- hash = ( hash * PRIME ) ^ iter . CurrentKeyString . GetHashCode ( ) ;
1810
- TValue ? value = iter . CurrentValue ;
1811
- hash = ( hash * PRIME ) ^ ( value is null ? 0 : JCG . EqualityComparer < TValue > . Default . GetHashCode ( value ) ) ;
1809
+ while ( iter . MoveNext ( ) )
1810
+ {
1811
+ hash = ( hash * PRIME ) ^ iter . CurrentKeyString . GetHashCode ( ) ;
1812
+ TValue ? value = iter . CurrentValue ;
1813
+ hash = ( hash * PRIME ) ^
1814
+ ( value is null ? 0 : JCG . EqualityComparer < TValue > . Default . GetHashCode ( value ) ) ;
1815
+ }
1812
1816
}
1817
+
1818
+ return hash ;
1813
1819
}
1814
- return hash ;
1815
1820
}
1816
1821
1817
1822
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
@@ -1832,16 +1837,22 @@ private int GetHashCode(char[] text, int startIndex, int length)
1832
1837
{
1833
1838
for ( int i = startIndex ; i < stop ; )
1834
1839
{
1835
- int codePointAt = charUtils . CodePointAt ( text , i , stop ) ;
1836
- code = code * 31 + Character . ToLower ( codePointAt , CultureInfo . InvariantCulture ) ; // LUCENENET specific - need to use invariant culture to match Java
1837
- i += Character . CharCount ( codePointAt ) ;
1840
+ unchecked
1841
+ {
1842
+ int codePointAt = charUtils . CodePointAt ( text , i , stop ) ;
1843
+ code = code * 31 + Character . ToLower ( codePointAt , CultureInfo . InvariantCulture ) ; // LUCENENET specific - need to use invariant culture to match Java
1844
+ i += Character . CharCount ( codePointAt ) ;
1845
+ }
1838
1846
}
1839
1847
}
1840
1848
else
1841
1849
{
1842
1850
for ( int i = startIndex ; i < stop ; i ++ )
1843
1851
{
1844
- code = code * 31 + text [ i ] ;
1852
+ unchecked
1853
+ {
1854
+ code = code * 31 + text [ i ] ;
1855
+ }
1845
1856
}
1846
1857
}
1847
1858
return code ;
@@ -1859,16 +1870,22 @@ private int GetHashCode(ICharSequence text)
1859
1870
{
1860
1871
for ( int i = 0 ; i < length ; )
1861
1872
{
1862
- int codePointAt = charUtils . CodePointAt ( text , i ) ;
1863
- code = code * 31 + Character . ToLower ( codePointAt , CultureInfo . InvariantCulture ) ; // LUCENENET specific - need to use invariant culture to match Java
1864
- i += Character . CharCount ( codePointAt ) ;
1873
+ unchecked
1874
+ {
1875
+ int codePointAt = charUtils . CodePointAt ( text , i ) ;
1876
+ code = code * 31 + Character . ToLower ( codePointAt , CultureInfo . InvariantCulture ) ; // LUCENENET specific - need to use invariant culture to match Java
1877
+ i += Character . CharCount ( codePointAt ) ;
1878
+ }
1865
1879
}
1866
1880
}
1867
1881
else
1868
1882
{
1869
1883
for ( int i = 0 ; i < length ; i ++ )
1870
1884
{
1871
- code = code * 31 + text [ i ] ;
1885
+ unchecked
1886
+ {
1887
+ code = code * 31 + text [ i ] ;
1888
+ }
1872
1889
}
1873
1890
}
1874
1891
return code ;
@@ -1886,16 +1903,22 @@ private int GetHashCode(string text)
1886
1903
{
1887
1904
for ( int i = 0 ; i < length ; )
1888
1905
{
1889
- int codePointAt = charUtils . CodePointAt ( text , i ) ;
1890
- code = code * 31 + Character . ToLower ( codePointAt , CultureInfo . InvariantCulture ) ; // LUCENENET specific - need to use invariant culture to match Java
1891
- i += Character . CharCount ( codePointAt ) ;
1906
+ unchecked
1907
+ {
1908
+ int codePointAt = charUtils . CodePointAt ( text , i ) ;
1909
+ code = code * 31 + Character . ToLower ( codePointAt , CultureInfo . InvariantCulture ) ; // LUCENENET specific - need to use invariant culture to match Java
1910
+ i += Character . CharCount ( codePointAt ) ;
1911
+ }
1892
1912
}
1893
1913
}
1894
1914
else
1895
1915
{
1896
1916
for ( int i = 0 ; i < length ; i ++ )
1897
1917
{
1898
- code = code * 31 + text [ i ] ;
1918
+ unchecked
1919
+ {
1920
+ code = code * 31 + text [ i ] ;
1921
+ }
1899
1922
}
1900
1923
}
1901
1924
return code ;
0 commit comments