Process_compare: reorder checks

Check for result being 0 first, before checking if the result might be
negated, so we do not need to negate 0.
This commit is contained in:
Christian Göttsche 2021-03-12 16:44:46 +01:00
parent 9adcd9051a
commit bea7f8e7af
1 changed files with 1 additions and 4 deletions

View File

@ -513,14 +513,11 @@ int Process_compare(const void* v1, const void* v2) {
int result = Process_compareByKey(p1, p2, key);
if (Settings_getActiveDirection(settings) != 1)
result = -result;
// Implement tie-breaker (needed to make tree mode more stable)
if (!result)
return SPACESHIP_NUMBER(p1->pid, p2->pid);
return result;
return (Settings_getActiveDirection(settings) == 1) ? result : -result;
}
static uint8_t stateCompareValue(char state) {