|
1 | | -///////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 1 | +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
2 | 2 | // Tencent is pleased to support the open source community by making behaviac available. |
3 | 3 | // |
4 | 4 | // Copyright (C) 2015-2017 THL A29 Limited, a Tencent company. All rights reserved. |
@@ -1818,37 +1818,41 @@ public static EOperatorType ParseOperatorType(string operatorType) |
1818 | 1818 |
|
1819 | 1819 | publicstaticboolCompare<T>(Tleft,Tright,EOperatorTypecomparisonType) |
1820 | 1820 | { |
1821 | | -boolbLeftNull=(left==null); |
1822 | | -boolbRightNull=(right==null); |
1823 | | - |
1824 | | -if(bLeftNull&&bRightNull)// both are null |
1825 | | -{ |
1826 | | -if(comparisonType==EOperatorType.E_EQUAL) |
1827 | | -{ |
1828 | | -returntrue; |
1829 | | -} |
1830 | | -elseif(comparisonType==EOperatorType.E_NOTEQUAL) |
1831 | | -{ |
1832 | | -returnfalse; |
1833 | | -} |
1834 | | -else |
1835 | | -{ |
1836 | | -Debug.Check(false); |
1837 | | -} |
1838 | | -} |
1839 | | -elseif(bLeftNull||bRightNull)// one is null and ther other one is not null |
| 1821 | +Typetype=typeof(T); |
| 1822 | +if(!type.IsValueType) |
1840 | 1823 | { |
1841 | | -if(comparisonType==EOperatorType.E_EQUAL) |
1842 | | -{ |
1843 | | -returnfalse; |
1844 | | -} |
1845 | | -elseif(comparisonType==EOperatorType.E_NOTEQUAL) |
| 1824 | +boolbLeftNull=(left==null); |
| 1825 | +boolbRightNull=(right==null); |
| 1826 | + |
| 1827 | +if(bLeftNull&&bRightNull)// both are null |
1846 | 1828 | { |
1847 | | -returntrue; |
| 1829 | +if(comparisonType==EOperatorType.E_EQUAL) |
| 1830 | +{ |
| 1831 | +returntrue; |
| 1832 | +} |
| 1833 | +elseif(comparisonType==EOperatorType.E_NOTEQUAL) |
| 1834 | +{ |
| 1835 | +returnfalse; |
| 1836 | +} |
| 1837 | +else |
| 1838 | +{ |
| 1839 | +Debug.Check(false); |
| 1840 | +} |
1848 | 1841 | } |
1849 | | -else |
| 1842 | +elseif(bLeftNull||bRightNull)// one is null and the other is not null |
1850 | 1843 | { |
1851 | | -Debug.Check(false); |
| 1844 | +if(comparisonType==EOperatorType.E_EQUAL) |
| 1845 | +{ |
| 1846 | +returnfalse; |
| 1847 | +} |
| 1848 | +elseif(comparisonType==EOperatorType.E_NOTEQUAL) |
| 1849 | +{ |
| 1850 | +returntrue; |
| 1851 | +} |
| 1852 | +else |
| 1853 | +{ |
| 1854 | +Debug.Check(false); |
| 1855 | +} |
1852 | 1856 | } |
1853 | 1857 | } |
1854 | 1858 |
|
@@ -1878,15 +1882,9 @@ public static bool Compare<T>(T left, T right, EOperatorType comparisonType) |
1878 | 1882 | } |
1879 | 1883 | } |
1880 | 1884 |
|
1881 | | -Typetype=typeof(T); |
1882 | | - |
1883 | 1885 | if(!type.IsValueType) |
1884 | 1886 | { |
1885 | | -// reference type |
1886 | | -objectl=(object)left; |
1887 | | -objectr=(object)right; |
1888 | | - |
1889 | | -boolbEqual=Object.ReferenceEquals(l,r); |
| 1887 | +boolbEqual=Object.ReferenceEquals(left,right); |
1890 | 1888 |
|
1891 | 1889 | if(bEqual) |
1892 | 1890 | { |
|