Changeset 3563 for libpipi


Ignore:
Timestamp:
Jul 22, 2009, 2:09:34 PM (11 years ago)
Author:
Sam Hocevar
Message:

Improve the median filter performance.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/pipi/filter/median.c

    r3342 r3563  
    2929static int cmpint(void const *i1, void const *i2)
    3030{
    31     return *(double const *)i1 < *(double const *)i2;
     31    /* On Linux amd64, this is 20 to 30 % faster than using a real
     32     * comparison (which wouldn't work on Windows since it expects both
     33     * negative and positive values), a ternary operator, or floats instead
     34     * of doubles. */
     35    union { int32_t i; double d; } u;
     36    u.d = *(double const *)i1 - *(double const *)i2;
     37    return u.i;
    3238}
    3339
Note: See TracChangeset for help on using the changeset viewer.