summaryrefslogtreecommitdiffstats
path: root/test/btree_test.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-08-13 17:26:00 +0200
committerDavid Robillard <d@drobilla.net>2020-08-13 17:26:00 +0200
commit4215a8ab7cc004c617b91a1628dbad3f19fbbe30 (patch)
treefbd27e5d1dd2e185a7bb9b054091cb47cea5c3fe /test/btree_test.c
parentd86638c91f89187f72afc532baf565ded0a29b7f (diff)
downloadzix-4215a8ab7cc004c617b91a1628dbad3f19fbbe30.tar.gz
zix-4215a8ab7cc004c617b91a1628dbad3f19fbbe30.tar.bz2
zix-4215a8ab7cc004c617b91a1628dbad3f19fbbe30.zip
Shrink some code
Diffstat (limited to 'test/btree_test.c')
-rw-r--r--test/btree_test.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/test/btree_test.c b/test/btree_test.c
index 67419be..7c470c0 100644
--- a/test/btree_test.c
+++ b/test/btree_test.c
@@ -40,10 +40,10 @@ unique_rand(size_t i)
static const uint32_t prime = 4294967291;
if (i >= prime) {
return i; // Values >= prime are mapped to themselves
- } else {
- const uint64_t residue = ((uint64_t)i * i) % prime;
- return (i <= prime / 2) ? residue : prime - residue;
}
+
+ const uint64_t residue = ((uint64_t)i * i) % prime;
+ return (i <= prime / 2) ? residue : prime - residue;
}
static int
@@ -51,14 +51,8 @@ int_cmp(const void* a, const void* b, const void* ZIX_UNUSED(user_data))
{
const uintptr_t ia = (uintptr_t)a;
const uintptr_t ib = (uintptr_t)b;
- // note the (ia - ib) trick here would overflow
- if (ia == ib) {
- return 0;
- } else if (ia < ib) {
- return -1;
- } else {
- return 1;
- }
+
+ return ia < ib ? -1 : ia > ib ? 1 : 0;
}
static uintptr_t