summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-02-04 09:03:30 +0100
committerTyge Løvset <[email protected]>2021-02-04 09:03:30 +0100
commit11a68c946912b7c9edfcbdb1345d26baf70e2c99 (patch)
treedb7a83ef07ee534df1c247b877a40a4e56e7067b
parent90ebc2d86c62ed2eecf17eeb5d9fddad690b666d (diff)
downloadSTC-modified-11a68c946912b7c9edfcbdb1345d26baf70e2c99.tar.gz
STC-modified-11a68c946912b7c9edfcbdb1345d26baf70e2c99.zip
Removed some unneeded tests.
-rw-r--r--examples/csmap_ex.c9
-rw-r--r--stc/csmap.h5
2 files changed, 5 insertions, 9 deletions
diff --git a/examples/csmap_ex.c b/examples/csmap_ex.c
index 7e4eb7c4..7b3692ed 100644
--- a/examples/csmap_ex.c
+++ b/examples/csmap_ex.c
@@ -21,15 +21,12 @@ int main(int argc, char **argv)
c_forrange (i, n) {
uint64_t val = stc64_random() & mask;
csmap_i_emplace(&map, val, i);
- if (!csmap_i_contains(&map, val)) {
- printf("Not found: %zu, %zu: ", i, val);
- }
}
printf("size %zu\n\n", csmap_i_size(map));
stc64_srandom(seed);
c_forrange (n - 20)
csmap_i_erase(&map, stc64_random() & mask);
-
+
size_t val = 500000;
csmap_i_emplace(&map, val, 5);
@@ -39,7 +36,7 @@ int main(int argc, char **argv)
csmap_i_find_it(&map, val, &it);
printf("\nmin/max: %d -- %d: found: %d. size: %zu\n", csmap_i_front(&map)->first,
- csmap_i_back(&map)->first,
+ csmap_i_back(&map)->first,
it.ref->first,
csmap_i_size(map));
c_foreach (i, csmap_i, it, csmap_i_end(&map))
@@ -53,6 +50,6 @@ int main(int argc, char **argv)
c_foreach (i, csset_str, shouts)
printf("shout: %s\n", i.ref->str);
-
+
csset_str_del(&shouts);
}
diff --git a/stc/csmap.h b/stc/csmap.h
index 20889573..4edbb277 100644
--- a/stc/csmap.h
+++ b/stc/csmap.h
@@ -391,7 +391,7 @@ int main(void) {
} \
static C##_##X##_size_t \
C##_##X##_split_(C##_##X##_node_t *d, C##_##X##_size_t tn) { \
- if (tn && d[d[d[tn].link[1]].link[1]].level == d[tn].level) { \
+ if (d[d[d[tn].link[1]].link[1]].level == d[tn].level) { \
C##_##X##_size_t tmp = d[tn].link[1]; \
d[tn].link[1] = d[tmp].link[0]; \
d[tmp].link[0] = tn; \
@@ -462,12 +462,11 @@ int main(void) {
if (d[d[tn].link[0]].level < d[tn].level - 1 || d[tx].level < d[tn].level - 1) { \
if (d[tx].level > --d[tn].level) \
d[tx].level = d[tn].level; \
- if ((tn = C##_##X##_skew_(d, tn))) { \
+ tn = C##_##X##_skew_(d, tn); \
tx = d[tn].link[1] = C##_##X##_skew_(d, d[tn].link[1]); \
d[tx].link[1] = C##_##X##_skew_(d, d[tx].link[1]); \
tn = C##_##X##_split_(d, tn); \
d[tn].link[1] = C##_##X##_split_(d, d[tn].link[1]); \
- } \
} \
return tn; \
} \