Skip to contentSkip to conversation

remove unnecessary 'if'

PATCH In review Alexander Potashev 1 participant 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 remove unnecessary 'if'

'patch->is_new' is always <= 0 at this point (look at 'assert' at the beginning of the function). In both cases ('is_new < 0' and 'is_new == 0') the result of those two lines is zeroing of 'is_new'.

---
 builtin-apply.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
builtin-apply.c +1 -2
index 4c4d1e1..904a748 100644
@@ -2440,8 +2440,7 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
 	if (!cached)
 		st_mode = ce_mode_from_stat(*ce, st->st_mode);
 
-	if (patch->is_new < 0)
-		patch->is_new = 0;
+	patch->is_new = 0;
 	if (!patch->old_mode)
 		patch->old_mode = st_mode;
 	if ((st_mode ^ patch->old_mode) & S_IFMT)
Signature · 1 line
1.6.0.4
#1 lore raw

Hello all!

What happened with this patch? Is it wrong or breaks comprehensibility?

Quoted 26 lines · Alexander Potashev

'patch->is_new' is always <= 0 at this point (look at 'assert' at the beginning of the function). In both cases ('is_new < 0' and 'is_new == 0') the result of those two lines is zeroing of 'is_new'.

---
 builtin-apply.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
builtin-apply.c +1 -2
index 4c4d1e1..904a748 100644
@@ -2440,8 +2440,7 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
 	if (!cached)
 		st_mode = ce_mode_from_stat(*ce, st->st_mode);
 
-	if (patch->is_new < 0)
-		patch->is_new = 0;
+	patch->is_new = 0;
 	if (!patch->old_mode)
 		patch->old_mode = st_mode;
 	if ((st_mode ^ patch->old_mode) & S_IFMT)
Signature · 1 line
1.6.0.4

Alexander