git: sbin/hammer: Make B-Tree walk a bit more effective

Tomohiro Kusumi tkusumi at crater.dragonflybsd.org
Thu Sep 24 07:46:36 PDT 2015


commit f1cf4f649f3abb55d93c4badf724ac78b272a3e1
Author: Tomohiro Kusumi <kusumi.tomohiro at gmail.com>
Date:   Sun Sep 20 16:53:25 2015 +0900

    sbin/hammer: Make B-Tree walk a bit more effective
    
    hammer show recursively calls print_btree_node() when node
    type is internal. If the node is not internal (leaf), it just
    prints records with no further B-Tree walk.
    
    Having
    node->type == HAMMER_BTREE_TYPE_INTERNAL
    check outside the
    for (i = 0; i < node->count; ++i) {
    is more effective since it doesn't go through unnecessary
    for loop (with max count=63) if the node isn't internal.
    
    Also note this looks more sane in the sense that node
    contains elms[] and node->type determines union type of elms,
    instead of node->type depends on each elms[i].

Summary of changes:
 sbin/hammer/cmd_show.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/f1cf4f649f3abb55d93c4badf724ac78b272a3e1


-- 
DragonFly BSD source repository



More information about the Commits mailing list