static bool accesscache_hashcmp(const void *a_v, const void *b_v) { const AccessCacheKey *a = (const AccessCacheKey *) a_v; const AccessCacheKey *b = (const AccessCacheKey *) b_v; #define COMPARE_FIELD(field) { \ if (a->clip_index != b->clip_index) { \ return false; \ } \ } (void) 0 COMPARE_FIELD(clip_index); COMPARE_FIELD(frame); COMPARE_FIELD(downscale); COMPARE_FIELD(input_mode); COMPARE_FIELD(transform_key); #undef COMPARE_FIELD return true; }
int Time::compare(Time& a, Time& b) { if (0 == strcmp(a.timezone, b.timezone)) { // if the timezones are the same, we can easily compare the two // times. Otherwise, convert to milliseconds and compare that. // This requires that object be normalized. COMPARE_FIELD(tm_year); COMPARE_FIELD(tm_mon); COMPARE_FIELD(tm_mday); COMPARE_FIELD(tm_hour); COMPARE_FIELD(tm_min); COMPARE_FIELD(tm_sec); return 0; } else { int64_t am = a.toMillis(false /* use isDst */); int64_t bm = b.toMillis(false /* use isDst */); int64_t diff = am-bm; return (diff < 0) ? -1 : ((diff > 0) ? 1 : 0); } }