threads / patch / 34883

patchsequencer: trivial cleanup

Subject: [PATCH] sequencer: trivial cleanup

## tl;dr

4 messages between Sep 8, 2013 and Sep 9, 2013. Diffs are folded; open one to read it.

replies: 3people: 3as markdown or json

Ramkumar Ramachandra· Sep 8, 2013, 22:42 UTC · lore
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 sequencer.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
Show changes to sequencer.c +1 −4
diff --git a/sequencer.c b/sequencer.c
index 351548f..8ed9f98 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -466,10 +466,7 @@ static int allow_empty(struct replay_opts *opts, struct commit *commit)
 	empty_commit = is_original_commit_empty(commit);
 	if (empty_commit < 0)
 		return empty_commit;
-	if (!empty_commit)
-		return 0;
-	else
-		return 1;
+	return empty_commit ? 0 : 1;
 }
 
 static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
-- 
1.8.4.100.gde18f6d.dirty
Felipe Contreras· Sep 8, 2013, 22:53 UTC · re: Ramkumar Ramachandra · lore

Re: [PATCH] sequencer: trivial cleanup

On Sun, Sep 8, 2013 at 5:42 PM, Ramkumar Ramachandra <artagnon@gmail.com> wrote:
Show 19 quoted lines
> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
> ---
>  sequencer.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/sequencer.c b/sequencer.c
> index 351548f..8ed9f98 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -466,10 +466,7 @@ static int allow_empty(struct replay_opts *opts, struct commit *commit)
>         empty_commit = is_original_commit_empty(commit);
>         if (empty_commit < 0)
>                 return empty_commit;
> -       if (!empty_commit)
> -               return 0;
> -       else
> -               return 1;
> +       return empty_commit ? 0 : 1;
>  }

Isn't it the other way around? Moreover, 'return !!empty_commit;' would be simpler.

-- 
Felipe Contreras
Ramkumar Ramachandra· Sep 8, 2013, 22:57 UTC · re: Felipe Contreras · lore

Re: [PATCH] sequencer: trivial cleanup

Felipe Contreras wrote:
Show 20 quoted lines
>>  sequencer.c | 5 +----
>>  1 file changed, 1 insertion(+), 4 deletions(-)
>>
>> diff --git a/sequencer.c b/sequencer.c
>> index 351548f..8ed9f98 100644
>> --- a/sequencer.c
>> +++ b/sequencer.c
>> @@ -466,10 +466,7 @@ static int allow_empty(struct replay_opts *opts, struct commit *commit)
>>         empty_commit = is_original_commit_empty(commit);
>>         if (empty_commit < 0)
>>                 return empty_commit;
>> -       if (!empty_commit)
>> -               return 0;
>> -       else
>> -               return 1;
>> +       return empty_commit ? 0 : 1;
>>  }
>
> Isn't it the other way around? Moreover, 'return !!empty_commit;'
> would be simpler.

Yeah, thanks for pointing out this grave stupidity. This seems to be inconsequential as far as the tests are concerned: have to do some major yak shaving.

SZEDER Gábor· Sep 9, 2013, 00:20 UTC · re: Felipe Contreras · lore

Re: [PATCH] sequencer: trivial cleanup

Hi,
On Sun, Sep 08, 2013 at 05:53:19PM -0500, Felipe Contreras wrote:
Show 23 quoted lines
> On Sun, Sep 8, 2013 at 5:42 PM, Ramkumar Ramachandra <artagnon@gmail.com> wrote:
> > Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
> > ---
> >  sequencer.c | 5 +----
> >  1 file changed, 1 insertion(+), 4 deletions(-)
> >
> > diff --git a/sequencer.c b/sequencer.c
> > index 351548f..8ed9f98 100644
> > --- a/sequencer.c
> > +++ b/sequencer.c
> > @@ -466,10 +466,7 @@ static int allow_empty(struct replay_opts *opts, struct commit *commit)
> >         empty_commit = is_original_commit_empty(commit);
> >         if (empty_commit < 0)
> >                 return empty_commit;
> > -       if (!empty_commit)
> > -               return 0;
> > -       else
> > -               return 1;
> > +       return empty_commit ? 0 : 1;
> >  }
> 
> Isn't it the other way around? Moreover, 'return !!empty_commit;'
> would be simpler.

Considering the possible return values from is_original_commit_empty(), I think all this could be written as

  return is_original_commit_empty(commit);

Best, Gábor

← back to recent threads