[FFmpeg-devel] [PATCH] ffplay: compact expression in compute_mod()
Stefano Sabatini
stefano.sabatini-lala at poste.it
Tue Apr 12 01:42:23 CEST 2011
On date Monday 2011-04-11 12:07:58 +0200, Michael Niedermayer encoded:
> On Mon, Apr 11, 2011 at 11:13:22AM +0200, Stefano Sabatini wrote:
> > Prefer "return X ? Y : Z" over "if (x) return Y; else return Z",
> > reduce line count.
> >
> > Signed-off-by: Stefano Sabatini <stefano.sabatini-lala at poste.it>
> > ---
> > ffplay.c | 5 +----
> > 1 files changed, 1 insertions(+), 4 deletions(-)
> >
> > diff --git a/ffplay.c b/ffplay.c
> > index 04e0343..a5f3b70 100644
> > --- a/ffplay.c
> > +++ b/ffplay.c
> > @@ -772,10 +772,7 @@ static void video_image_display(VideoState *is)
> > static inline int compute_mod(int a, int b)
> > {
> > a = a % b;
> > - if (a >= 0)
> > - return a;
> > - else
> > - return a + b;
> > + return a >= 0 ? a : a + b;
> > }
>
> shortest:
> return (a%b+b)%b;
>
> maybe a hair faster than shortest:
> return a<0 ? a%b+b : a%b;
Committed this variant.
> either way all 3 variants ok, pick what you prefer
--
FFmpeg = Forgiving Fancy Mournful Pitiless Enchanting Guru
More information about the ffmpeg-devel
mailing list