Skip to content
  • René Scharfe's avatar
    match-trees: simplify score_trees() using tree_entry() · d8febde3
    René Scharfe authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    Convert the loop in score_trees() to tree_entry().  The code becomes
    shorter and simpler because the calls to update_tree_entry() are not
    needed any more.
    
    Another benefit is that we need less variables to track the current
    tree entries; as a side-effect of that the compiler has an easier
    job figuring out the control flow and thus can avoid false warnings
    about uninitialized variables.
    
    Using struct name_entry also allows the use of tree_entry_len() for
    finding the path length instead of strlen(), which may be slightly
    more efficient.
    
    Also unify the handling of missing entries in one of the two trees
    (i.e. added or removed files): Just set cmp appropriately first, no
    matter if we ran off the end of a tree or if we actually have two
    entries to compare, and check its value a bit later without
    duplicating the handler code.
    
    Signed-off-by: default avatarRene Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    d8febde3