mirror of
https://gittea.dev/nova/th.git
synced 2025-10-22 02:40: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;
|
char result = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
is_num = 0;
|
|
||||||
|
|
||||||
if ((*a >= '0') && (*a <= '9')) {
|
if ((*a <= '9') && (*a >= '0')) {
|
||||||
parsed_number0 = 0;
|
parsed_number0 = 0;
|
||||||
while((*a >= '0') && (*a <= '9')) {
|
do {
|
||||||
parsed_number0 = (parsed_number0 * 10) + (*a - '0');
|
parsed_number0 = (parsed_number0 * 10) + (*a - '0');
|
||||||
a++;
|
a++;
|
||||||
}
|
} while((*a <= '9') && (*a >= '0'));
|
||||||
is_num |= 1;
|
is_num |= 1;
|
||||||
}
|
}
|
||||||
if ((*b >= '0') && (*b <= '9')) {
|
if ((*b <= '9') && (*b >= '0')) {
|
||||||
parsed_number1 = 0;
|
parsed_number1 = 0;
|
||||||
while((*b >= '0') && (*b <= '9')) {
|
do {
|
||||||
parsed_number1 = (parsed_number1 * 10) + (*b - '0');
|
parsed_number1 = (parsed_number1 * 10) + (*b - '0');
|
||||||
b++;
|
b++;
|
||||||
}
|
} while((*b <= '9') && (*b >= '0'));
|
||||||
is_num |= 2;
|
is_num |= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_num) {
|
if (is_num) {
|
||||||
if (is_num == 1) {
|
if (is_num == 1) {
|
||||||
if (*b < '0') {
|
if (*b > '9') {
|
||||||
result = 1;
|
|
||||||
} else {
|
|
||||||
result = -1;
|
result = -1;
|
||||||
|
} else {
|
||||||
|
result = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else if (is_num == 2) {
|
} else if (is_num == 2) {
|
||||||
if (*a < '0') {
|
if (*a > '9') {
|
||||||
result = -1;
|
|
||||||
} else {
|
|
||||||
result = 1;
|
result = 1;
|
||||||
|
} else {
|
||||||
|
result = -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else {
|
} 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
|
/* those breaks are not set here, due to the possibillity that both numbers are equal
|
||||||
* in which case the comparison should continue */
|
* in which case the comparison should continue */
|
||||||
|
is_num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char aa = ((*a >= 'A') && (*a <= 'Z')) ? (*a | ' ') : *a;
|
unsigned char aa = ((*a >= 'A') && (*a <= 'Z')) ? (*a | ' ') : *a;
|
||||||
|
Reference in New Issue
Block a user