On Sat, Oct 24, 2015 at 9:38 PM, Mark Harris <mark....@gmail.com> wrote: >>> >>> static int compare_int64(const void *a, const void *b) >>> { >>> - int64_t va = *(int64_t *)a, vb = *(int64_t *)b; >>> - return va < vb ? -1 : va > vb ? +1 : 0; >>> + return *(const int64_t *)a - *(const int64_t *)b; >>> } >>> >> >> What if the result doesn't fit in int? The input is not int. > > Even for int this transformation is not valid assuming that the full > range of int is possible. For example if *a = INT_MAX and *b = -1 > then *a - *b = INT_MAX+1 which is negative when cast to an int.
point taken, but this will need to be checked more carefully: for instance, sometimes the integers fit in only the lower 24/16 bits, etc. I have decided the following: this patch will only address the const-ness. The next patch will be a scan through the qsort comparators, and appropriately modifying the comparator by fixing existing issues (if any) related to your point, and avoiding branches when possibles. _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel