summaryrefslogtreecommitdiff
path: root/src/set-fields.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2022-05-17 19:17:12 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2022-05-17 19:30:55 -0700
commit5864e8f919c3dae827016ac1a78544db90403b6d (patch)
treef2fe230d81ec8b9d6fe256ff5e0b6caca7fff087 /src/set-fields.c
parent9f2fa50748e52046ea3b99bd469f846ef8827272 (diff)
downloadcoreutils-5864e8f919c3dae827016ac1a78544db90403b6d.tar.gz
maint: simplify comparisons
* src/comm.c (compare_files): * src/join.c (keycmp): * src/ls.c (off_cmp): * src/ptx.c (compare_words, compare_occurs): * src/set-fields.c (compare_ranges): Prefer ((a > b) - (a < b)) to variants like (a < b ? -1 : a > b) as it’s typically faster these days.
Diffstat (limited to 'src/set-fields.c')
-rw-r--r--src/set-fields.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/set-fields.c b/src/set-fields.c
index 575dc2784..670706f1c 100644
--- a/src/set-fields.c
+++ b/src/set-fields.c
@@ -55,13 +55,12 @@ add_range_pair (uintmax_t lo, uintmax_t hi)
/* Comparison function for qsort to order the list of
- struct range_pairs. */
+ struct field_range_pairs. */
static int
compare_ranges (const void *a, const void *b)
{
- int a_start = ((const struct field_range_pair *) a)->lo;
- int b_start = ((const struct field_range_pair *) b)->lo;
- return a_start < b_start ? -1 : a_start > b_start;
+ struct field_range_pair const *ap = a, *bp = b;
+ return (ap->lo > bp->lo) - (ap->lo < bp->lo);
}
/* Reallocate Range Pair entries, with corresponding