mirror of
https://gittea.dev/nova/th.git
synced 2025-10-21 10:20:15 -04:00
slight likely branch improvements
This commit is contained in:
26
sorting.c
26
sorting.c
@@ -43,38 +43,37 @@ int sort_natural(const void *file0, const void *file1){
|
||||
char result = 0;
|
||||
|
||||
do {
|
||||
is_num = 0;
|
||||
|
||||
if ((*a >= '0') && (*a <= '9')) {
|
||||
if ((*a <= '9') && (*a >= '0')) {
|
||||
parsed_number0 = 0;
|
||||
while((*a >= '0') && (*a <= '9')) {
|
||||
do {
|
||||
parsed_number0 = (parsed_number0 * 10) + (*a - '0');
|
||||
a++;
|
||||
}
|
||||
} while((*a <= '9') && (*a >= '0'));
|
||||
is_num |= 1;
|
||||
}
|
||||
if ((*b >= '0') && (*b <= '9')) {
|
||||
if ((*b <= '9') && (*b >= '0')) {
|
||||
parsed_number1 = 0;
|
||||
while((*b >= '0') && (*b <= '9')) {
|
||||
do {
|
||||
parsed_number1 = (parsed_number1 * 10) + (*b - '0');
|
||||
b++;
|
||||
}
|
||||
} while((*b <= '9') && (*b >= '0'));
|
||||
is_num |= 2;
|
||||
}
|
||||
|
||||
if (is_num) {
|
||||
if (is_num == 1) {
|
||||
if (*b < '0') {
|
||||
result = 1;
|
||||
} else {
|
||||
if (*b > '9') {
|
||||
result = -1;
|
||||
} else {
|
||||
result = 1;
|
||||
}
|
||||
break;
|
||||
} else if (is_num == 2) {
|
||||
if (*a < '0') {
|
||||
result = -1;
|
||||
} else {
|
||||
if (*a > '9') {
|
||||
result = 1;
|
||||
} else {
|
||||
result = -1;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
@@ -88,6 +87,7 @@ int sort_natural(const void *file0, const void *file1){
|
||||
}
|
||||
/* those breaks are not set here, due to the possibillity that both numbers are equal
|
||||
* in which case the comparison should continue */
|
||||
is_num = 0;
|
||||
}
|
||||
|
||||
unsigned char aa = ((*a >= 'A') && (*a <= 'Z')) ? (*a | ' ') : *a;
|
||||
|
Reference in New Issue
Block a user