mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
enhance: improve NumericSort.Compare
performance
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
651d313496
commit
489b57858f
1 changed files with 5 additions and 2 deletions
|
@ -21,6 +21,10 @@
|
|||
int loc2 = 0;
|
||||
|
||||
bool isDigit1 = char.IsDigit(c1);
|
||||
bool isDigit2 = char.IsDigit(c2);
|
||||
if (isDigit1 != isDigit2)
|
||||
return c1.CompareTo(c2);
|
||||
|
||||
do
|
||||
{
|
||||
tmp1[loc1] = c1;
|
||||
|
@ -33,7 +37,6 @@
|
|||
break;
|
||||
} while (char.IsDigit(c1) == isDigit1);
|
||||
|
||||
bool isDigit2 = char.IsDigit(c2);
|
||||
do
|
||||
{
|
||||
tmp2[loc2] = c2;
|
||||
|
@ -49,7 +52,7 @@
|
|||
string sub1 = new string(tmp1, 0, loc1);
|
||||
string sub2 = new string(tmp2, 0, loc2);
|
||||
int result;
|
||||
if (isDigit1 && isDigit2)
|
||||
if (isDigit1)
|
||||
result = loc1 == loc2 ? string.CompareOrdinal(sub1, sub2) : loc1 - loc2;
|
||||
else
|
||||
result = string.CompareOrdinal(sub1, sub2);
|
||||
|
|
Loading…
Reference in a new issue