summaryrefslogtreecommitdiffstats
path: root/src/sord.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2017-12-16 11:55:38 +0100
committerDavid Robillard <d@drobilla.net>2017-12-16 14:00:28 +0100
commit0aab4478058a006819549e40946dc23dce05bafa (patch)
treefdb4e2c29d1cd32650457db4583edd6ef62d000c /src/sord.c
parent46b8e6ed53370d76c294c5e40b040ea78d6c9847 (diff)
downloadsord-0aab4478058a006819549e40946dc23dce05bafa.tar.gz
sord-0aab4478058a006819549e40946dc23dce05bafa.tar.bz2
sord-0aab4478058a006819549e40946dc23dce05bafa.zip
Fix various minor style issues
Diffstat (limited to 'src/sord.c')
-rw-r--r--src/sord.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/sord.c b/src/sord.c
index 218234b..a2a4f07 100644
--- a/src/sord.c
+++ b/src/sord.c
@@ -50,7 +50,7 @@
#define NUM_ORDERS 12
#define STATEMENT_LEN 3
-#define TUP_LEN STATEMENT_LEN + 1
+#define TUP_LEN (STATEMENT_LEN + 1)
#define DEFAULT_ORDER SPO
#define DEFAULT_GRAPH_ORDER GSPO
@@ -328,9 +328,11 @@ sord_iter_forward(SordIter* iter)
zix_btree_iter_increment(iter->cur);
while (!zix_btree_iter_is_end(iter->cur)) {
key = (SordNode**)zix_btree_get(iter->cur);
- for (int i = 0; i < 3; ++i)
- if (key[i] != initial[i])
+ for (int i = 0; i < 3; ++i) {
+ if (key[i] != initial[i]) {
return false;
+ }
+ }
zix_btree_iter_increment(iter->cur);
}
@@ -349,8 +351,9 @@ sord_iter_seek_match(SordIter* iter)
!zix_btree_iter_is_end(iter->cur);
sord_iter_forward(iter)) {
const SordNode** const key = (const SordNode**)zix_btree_get(iter->cur);
- if (sord_quad_match_inline(key, iter->pat))
+ if (sord_quad_match_inline(key, iter->pat)) {
return (iter->end = false);
+ }
}
return true;
}
@@ -368,8 +371,9 @@ sord_iter_seek_match_range(SordIter* iter)
do {
const SordNode** key = (const SordNode**)zix_btree_get(iter->cur);
- if (sord_quad_match_inline(key, iter->pat))
+ if (sord_quad_match_inline(key, iter->pat)) {
return false; // Found match
+ }
for (int i = 0; i < iter->n_prefix; ++i) {
const int idx = orderings[iter->order][i];
@@ -726,8 +730,9 @@ sord_drop_quad_ref(SordModel* sord, const SordNode* node, SordQuadIndex i)
void
sord_free(SordModel* sord)
{
- if (!sord)
+ if (!sord) {
return;
+ }
// Free nodes
SordQuad tup;
@@ -748,9 +753,11 @@ sord_free(SordModel* sord)
zix_btree_iter_free(t);
// Free indices
- for (unsigned o = 0; o < NUM_ORDERS; ++o)
- if (sord->indices[o])
+ for (unsigned o = 0; o < NUM_ORDERS; ++o) {
+ if (sord->indices[o]) {
zix_btree_free(sord->indices[o]);
+ }
+ }
free(sord);
}
@@ -788,8 +795,9 @@ sord_begin(const SordModel* sord)
SordIter*
sord_find(SordModel* sord, const SordQuad pat)
{
- if (!pat[0] && !pat[1] && !pat[2] && !pat[3])
+ if (!pat[0] && !pat[1] && !pat[2] && !pat[3]) {
return sord_begin(sord);
+ }
SearchMode mode;
int n_prefix;
@@ -798,8 +806,9 @@ sord_find(SordModel* sord, const SordQuad pat)
SORD_FIND_LOG("Find " TUP_FMT " index=%s mode=%d n_prefix=%d\n",
TUP_FMT_ARGS(pat), order_names[index_order], mode, n_prefix);
- if (pat[0] && pat[1] && pat[2] && pat[3])
+ if (pat[0] && pat[1] && pat[2] && pat[3]) {
mode = SINGLE; // No duplicate quads (Sord is a set)
+ }
ZixBTree* const db = sord->indices[index_order];
ZixBTreeIter* cur = NULL;
@@ -1218,8 +1227,9 @@ sord_add(SordModel* sord, const SordQuad tup)
}
}
- for (int i = 0; i < TUP_LEN; ++i)
+ for (int i = 0; i < TUP_LEN; ++i) {
sord_add_quad_ref(sord, tup[i], (SordQuadIndex)i);
+ }
++sord->n_quads;
return true;
@@ -1245,8 +1255,9 @@ sord_remove(SordModel* sord, const SordQuad tup)
free(quad);
- for (int i = 0; i < TUP_LEN; ++i)
+ for (int i = 0; i < TUP_LEN; ++i) {
sord_drop_quad_ref(sord, tup[i], (SordQuadIndex)i);
+ }
--sord->n_quads;
}
@@ -1278,8 +1289,9 @@ sord_erase(SordModel* sord, SordIter* iter)
free(quad);
- for (int i = 0; i < TUP_LEN; ++i)
+ for (int i = 0; i < TUP_LEN; ++i) {
sord_drop_quad_ref(sord, tup[i], (SordQuadIndex)i);
+ }
--sord->n_quads;
return SERD_SUCCESS;