summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoern Engel <joern@logfs.org>2012-01-16 15:18:39 -0800
committerJoern Engel <joern@logfs.org>2012-01-16 15:18:39 -0800
commit76cb4bd61325d0d93de251a5878b9e587c0f0325 (patch)
tree944b672221898de10b59c5c2b961a732fe9246b7
parent8e82320bb8f943e3df6daaaebead65eea6c71f26 (diff)
downloadcancd-76cb4bd61325d0d93de251a5878b9e587c0f0325.tar.gz
Compile btree library in
Also remove AGGRESSIVE_COMPACTION, as we won't need it and silence a (wrong) compiler warning. Signed-off-by: Joern Engel <joern@logfs.org>
-rw-r--r--Makefile2
-rw-r--r--btree.c48
2 files changed, 2 insertions, 48 deletions
diff --git a/Makefile b/Makefile
index 498c9d3..d909228 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@ VERSION=0.1.0
CFLAGS += -Wall -g -O2 -DVERSION="\"$(VERSION)\""
-cancd: cancd.o
+cancd: cancd.o btree.o
install:
mkdir -p $(DESTDIR)/usr/sbin
diff --git a/btree.c b/btree.c
index 8a7a8b6..af9fcc9 100644
--- a/btree.c
+++ b/btree.c
@@ -37,15 +37,6 @@
#include <errno.h>
#include "btree.h"
-/*
- * Depending on the ratio of lookups vs. insert and removes, it may be
- * beneficial to spend more work trying to keep the tree as compact as
- * possible. With roughly 50 lookups for every insert/remove, stealing
- * from neighbours becomes more effective. If that is the case, please
- * define AGGRESSIVE_COMPACTION below
- */
-// #define AGGRESSIVE_COMPACTION
-
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define NODESIZE MAX(L1_CACHE_BYTES, 128)
@@ -412,43 +403,6 @@ static int split(struct btree_head *head, struct btree_geo *geo,
static int rebalance_insert(struct btree_head *head, struct btree_geo *geo,
unsigned long *key, unsigned long *child, int level)
{
-#ifdef AGGRESSIVE_COMPACTION
- unsigned long *parent, *left, *right;
- int child_no, no_left, no_right, delta;
-
- if (level == head->height)
- goto split;
-
- parent = find_level(head, geo, key, level + 1);
- child_no = getpos(geo, parent, key);
- BUG_ON(bval(geo, parent, child_no) != (unsigned long)child);
-
- if (child_no > 0) {
- left = (unsigned long *)bval(geo, parent, child_no - 1);
- no_left = getfill(geo, left, 0);
- delta = geo->no_pairs - no_left;
- if (delta >= 2) {
- steal_r(head, geo, level,
- left, no_left,
- child, geo->no_pairs,
- parent, child_no - 1, delta / 2);
- return 0;
- }
- }
- if (child_no + 1 < getfill(geo, parent, child_no)) {
- right = (unsigned long *)bval(geo, parent, child_no + 1);
- no_right = getfill(geo, right, 0);
- delta = geo->no_pairs - no_right;
- if (delta >= 2) {
- steal_l(head, geo, level,
- child, geo->no_pairs,
- right, no_right,
- parent, child_no, delta / 2);
- return 0;
- }
- }
-split:
-#endif
return split(head, geo, child, level);
}
@@ -524,7 +478,7 @@ static void rebalance(struct btree_head *head, struct btree_geo *geo,
unsigned long *key, int level, unsigned long *child, int fill)
{
unsigned long *parent, *left = NULL, *right = NULL;
- int child_no, no_left, no_right, i;
+ int child_no, no_left, no_right = no_right, i;
parent = find_level(head, geo, key, level + 1);
child_no = getpos(geo, parent, key);