From 0d8336e1d3833c1d896e55e97fc0bcb1206ac96e Mon Sep 17 00:00:00 2001 From: Warren Dukes Date: Fri, 4 Aug 2006 12:09:56 +0000 Subject: set CHILDREN_PER_NODE to 31, and uncomment out closeMp3Directory since this appears to now be fast git-svn-id: https://svn.musicpd.org/mpd/branches/mpd-tree@4546 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/tree.c | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) (limited to 'src/tree.c') diff --git a/src/tree.c b/src/tree.c index 74159ab29..63bed7f41 100644 --- a/src/tree.c +++ b/src/tree.c @@ -23,7 +23,7 @@ #include #ifndef CHILDREN_PER_NODE -#define CHILDREN_PER_NODE 3 +#define CHILDREN_PER_NODE 31 #endif #define DATA_PER_NODE (CHILDREN_PER_NODE-1) @@ -46,7 +46,7 @@ struct _TreeNode struct _Tree { - TreeCompareKeyFunction compareData; + TreeCompareKeyFunction compareKey; TreeFreeFunction freeKey; TreeFreeFunction freeData; TreeNode * rootNode; @@ -83,7 +83,7 @@ _FindPosition(Tree * tree, TreeNode * node, void * key, int * pos) while (high > low) { int cur = (high + low) >> 1; - cmp = tree->compareKey(data, node->keyData[cur].key); + cmp = tree->compareKey(key, node->keyData[cur].key); if (cmp > 0) { low = cur+1; @@ -106,7 +106,7 @@ _FindPosition(Tree * tree, TreeNode * node, void * key, int * pos) int cmp = -1; for (; i < node->count && - (cmp = tree->compareData(key, node->keyData[i].key)) > 0; + (cmp = tree->compareKey(key, node->keyData[i].key)) > 0; i++); *pos = i; return (cmp == 0); @@ -179,9 +179,6 @@ _InsertNodeAndData(Tree * tree, TreeKeyData keyData) { assert(node->count < DATA_PER_NODE); -#ifdef TREE_DEBUG - assert(!newNode || tree->compareData(data, newNode->keyData[0]) < 0); -#endif int j = node->count; for (; j > pos; j--) @@ -194,11 +191,6 @@ _InsertNodeAndData(Tree * tree, } } -#ifdef TREE_DEBUG - assert(!node->children[pos] || - tree->compareData(data, node->children[pos]->keyData[0]) > 0); -#endif - node->keyData[pos] = keyData; node->count++; @@ -219,10 +211,6 @@ _AddDataToSplitNodes(Tree * tree, TreeNode * newNode, TreeKeyData keyData) { -#ifdef TREE_DEBUG - assert(newNode == NULL || - tree->compareData(data, newNode->keyData[0]) < 0); -#endif assert(moreNode->children[0] == NULL); TreeKeyData retKeyData; @@ -281,11 +269,6 @@ _InsertAt(TreeIterator * iter, TreeKeyData keyData) while (node != NULL) { -#ifdef TREE_DEBUG - assert((pos == node->count || - iter->tree->compareData(data, node->keyData[pos]) < 0)); -#endif - // see if there's any NULL data in the current node if (node->count == DATA_PER_NODE) { @@ -581,12 +564,12 @@ _DeleteAt(TreeIterator * iter) /************************* PUBLIC METHODS ***********************************/ Tree * -MakeTree(TreeCompareKeyFunction compareData, +MakeTree(TreeCompareKeyFunction compareKey, TreeFreeFunction freeKey, TreeFreeFunction freeData) { Tree * ret = malloc(sizeof(Tree)); - ret->compareData = compareData; + ret->compareKey = compareKey; ret->freeKey = freeKey; ret->freeData = freeData; ret->rootNode = _MakeNode(); -- cgit v1.2.3