Permalink
Browse files

refs #100761 Simplify ccn_btree_prev_leaf() by using ccn_btree_index_…

…in_parent.
  • Loading branch information...
1 parent bacb35c commit d2fbf0f8e82be294d89d280a5a65e0fa0cdc4aa6 Michael Plass committed May 19, 2012
Showing with 2 additions and 10 deletions.
  1. +2 −10 csrc/lib/ccn_btree.c
View
@@ -1175,23 +1175,15 @@ ccn_btree_prev_leaf(struct ccn_btree *btree,
struct ccn_btree_node *parent = NULL;
int ans;
int i;
- int n;
ans = -1;
p = node;
while (p->parent != 0) {
parent = ccn_btree_getnode(btree, p->parent, 0);
if (parent == NULL)
goto Bail;
- n = ccn_btree_node_nent(parent);
- if (n < 0)
- goto Bail;
- /* Set i to our index in parent */
- for (i = n - 1; i > 0; i--) {
- e = ccn_btree_node_internal_entry(parent, i);
- if (MYFETCH(e, child) == p->nodeid)
- break;
- }
+ i = ccn_btree_index_in_parent(parent, p->nodeid);
+ if (i < 0) goto Bail;
if (i > 0) {
/* we can stop walking up the tree now, and walk down instead */
for (q = parent; ccn_btree_node_level(q) != 0;) {

0 comments on commit d2fbf0f

Please sign in to comment.