aboutsummaryrefslogtreecommitdiff
path: root/dsf.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2018-11-13 21:45:44 +0000
committerSimon Tatham <anakin@pobox.com>2018-11-13 21:48:24 +0000
commit5f5b284c0bddbe67de14b2d2bfb596bc7ba1298a (patch)
treef96b55a27088ae71d74dc83d7cc3731c5d5bf6dc /dsf.c
parenta550ea0a47374705a37f36b0f05ffe9e4c8161fb (diff)
downloadpuzzles-5f5b284c0bddbe67de14b2d2bfb596bc7ba1298a.zip
puzzles-5f5b284c0bddbe67de14b2d2bfb596bc7ba1298a.tar.gz
puzzles-5f5b284c0bddbe67de14b2d2bfb596bc7ba1298a.tar.bz2
puzzles-5f5b284c0bddbe67de14b2d2bfb596bc7ba1298a.tar.xz
Use C99 bool within source modules.
This is the main bulk of this boolification work, but although it's making the largest actual change, it should also be the least disruptive to anyone interacting with this code base downstream of me, because it doesn't modify any interface between modules: all the inter-module APIs were updated one by one in the previous commits. This just cleans up the code within each individual source file to use bool in place of int where I think that makes things clearer.
Diffstat (limited to 'dsf.c')
-rw-r--r--dsf.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/dsf.c b/dsf.c
index 88c5f94..832bb30 100644
--- a/dsf.c
+++ b/dsf.c
@@ -129,13 +129,13 @@ int edsf_canonify(int *dsf, int index, bool *inverse_return)
index = start_index;
while (index != canonical_index) {
int nextindex = dsf[index] >> 2;
- int nextinverse = inverse ^ (dsf[index] & 1);
+ bool nextinverse = inverse ^ (dsf[index] & 1);
dsf[index] = (canonical_index << 2) | inverse;
inverse = nextinverse;
index = nextindex;
}
- assert(inverse == 0);
+ assert(!inverse);
/* fprintf(stderr, "Return %2d\n", index); */
@@ -161,7 +161,6 @@ void edsf_merge(int *dsf, int v1, int v2, bool inverse)
if (v1 == v2)
assert(!inverse);
else {
- assert(inverse == 0 || inverse == 1);
/*
* We always make the smaller of v1 and v2 the new canonical
* element. This ensures that the canonical element of any
@@ -182,7 +181,7 @@ void edsf_merge(int *dsf, int v1, int v2, bool inverse)
v2 = v3;
}
dsf[v1] += (dsf[v2] >> 2) << 2;
- dsf[v2] = (v1 << 2) | !!inverse;
+ dsf[v2] = (v1 << 2) | inverse;
}
v2 = edsf_canonify(dsf, v2, &i2);