[FFmpeg-devel] [PATCH] all: simplify qsort comparators, and add const-correctness

Ganesh Ajjanagadde gajjanag at mit.edu
Sun Oct 25 16:17:06 CET 2015

On Sun, Oct 25, 2015 at 11:12 AM, Nicolas George <george at nsup.org> wrote:
> Le quartidi 4 brumaire, an CCXXIV, Ganesh Ajjanagadde a écrit :
>> Seems like the (x > y) - (x < y) trick works very well: GCC optimizes
>> it to branch-less code, and it is overflow safe:
>> https://stackoverflow.com/questions/10996418/efficient-integer-compare-function/10997428#10997428
>> Will submit patch to convert all qsort comparators (the ones for
>> integers) to this form, yielding two benefits:
> Nice. Maybe make it a macro: AV_DIFFSIGN(x, y).

Maybe more like FFDIFFSIGN, I don't think the AV_ prefix is ideal. FF
also has the advantage of being consistent with existing FFMIN, FFMAX,
FFABS, etc. Nevertheless, this is off-topic for this thread. We can
discuss further when I submit the patches.

> Regards,
> --
>   Nicolas George
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

More information about the ffmpeg-devel mailing list