René Scharfe <rene.scharfe@xxxxxxxxxxxxxx> writes: > Hmm, let's see if we can help the compiler follow the code without > making it harder for people to understand. The patch looks a bit > jumbled, but the resulting code is OK in my biased opinion. I actually think the result is much better than a mere "OK"; the duplicated "at this point we know path1 (or path2) is missing from the other side" has been bothering me and I was about to suggest a similar rewrite before I read your message ;-) However, the same compiler still thinks {elem,path,mode}1 can be used uninitialized (but not {elem,path,mode}2). The craziness I reported in the previous message is also the same. With this patch on top to swap the side we inspect first, the compiler thinks {elem,path,mode}2 can be used uninitialized but not the other three variables X-<. So I like your change for readability, but for GCC 4.4.5 we still need the unnecessary initialization. match-trees.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/match-trees.c b/match-trees.c index c0c66bb..9ea2c80 100644 --- a/match-trees.c +++ b/match-trees.c @@ -77,16 +77,16 @@ static int score_trees(const unsigned char *hash1, const unsigned char *hash2) unsigned mode1, mode2; int cmp = 0; - if (one.size) - elem1 = tree_entry_extract(&one, &path1, &mode1); - else - /* two has more entries */ - cmp = 1; if (two.size) elem2 = tree_entry_extract(&two, &path2, &mode2); else /* two lacks this entry */ cmp = -1; + if (one.size) + elem1 = tree_entry_extract(&one, &path1, &mode1); + else + /* two has more entries */ + cmp = 1; if (!cmp) cmp = base_name_compare(path1, strlen(path1), mode1, -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html