From a8bea729eb0226fdd4c577ccd7910e72f3f6a010 Mon Sep 17 00:00:00 2001 From: Tomohiro Kusumi Date: Fri, 9 Jan 2015 00:13:59 +0900 Subject: [PATCH] sys/vfs/hammer: make btree_search() climb up btree slightly faster This cleanup patch lets cursor climb up deep/fat btree slightly faster (lightweight), if not slower. The local variable enospc won't be anything other than 0 at this point thus (&& enospc == 0) isn't necessary here. Also node type checking is redundant as they both use btree_node_is_full(). There used to be btree_node_is_almost_full() and internal/leaf needed to be separated by if/else but not anymore. --- sys/vfs/hammer/hammer_btree.c | 11 +++-------- 1 files changed, 3 insertions(+), 8 deletions(-) diff --git a/sys/vfs/hammer/hammer_btree.c b/sys/vfs/hammer/hammer_btree.c index 6165ae5..7b397d6 100644 --- a/sys/vfs/hammer/hammer_btree.c +++ b/sys/vfs/hammer/hammer_btree.c @@ -1117,14 +1117,9 @@ btree_search(hammer_cursor_t cursor, int flags) * (If inserting we aren't doing an as-of search so we don't have * to worry about create_check). */ - while ((flags & HAMMER_CURSOR_INSERT) && enospc == 0) { - if (cursor->node->ondisk->type == HAMMER_BTREE_TYPE_INTERNAL) { - if (btree_node_is_full(cursor->node->ondisk) == 0) - break; - } else { - if (btree_node_is_full(cursor->node->ondisk) ==0) - break; - } + while (flags & HAMMER_CURSOR_INSERT) { + if (btree_node_is_full(cursor->node->ondisk) == 0) + break; if (cursor->node->ondisk->parent == 0 || cursor->parent->ondisk->count != HAMMER_BTREE_INT_ELMS) { break; -- 1.7.1