match-trees: simplify score_trees() using tree_entry()
commitd8febde370aa464a5208cf094f306343e4ecb6dc
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>
Sun, 24 Mar 2013 22:46:28 +0000 (24 23:46 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 25 Mar 2013 16:00:30 +0000 (25 09:00 -0700)
tree7787c467bcb876da2629452c2fa9e01d13926501
parent837154978e94586027e9684ecfbdfd4178c1c8aa
match-trees: simplify score_trees() using tree_entry()

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: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
match-trees.c