From 280f99688d68d83b8d1099b2f6bcc4579da771b0 Mon Sep 17 00:00:00 2001 From: compudj Date: Sat, 14 Aug 2004 20:36:28 +0000 Subject: [PATCH] tweak ltt_time_compare git-svn-id: http://ltt.polymtl.ca/svn@754 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/ltt/time.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ltt/branches/poly/ltt/time.h b/ltt/branches/poly/ltt/time.h index 83c2fb6c..55fb5883 100644 --- a/ltt/branches/poly/ltt/time.h +++ b/ltt/branches/poly/ltt/time.h @@ -63,13 +63,16 @@ static inline LttTime ltt_time_add(LttTime t1, LttTime t2) } +/* Fastest comparison : t1 > t2 */ static inline int ltt_time_compare(LttTime t1, LttTime t2) { - if(t1.tv_sec > t2.tv_sec) return 1; - if(t1.tv_sec < t2.tv_sec) return -1; - if(t1.tv_nsec > t2.tv_nsec) return 1; - if(t1.tv_nsec < t2.tv_nsec) return -1; - return 0; + int ret=0; + if(t1.tv_sec > t2.tv_sec) ret = 1; + else if(t1.tv_sec < t2.tv_sec) ret = -1; + else if(t1.tv_nsec > t2.tv_nsec) ret = 1; + else if(t1.tv_nsec < t2.tv_nsec) ret = -1; + + return ret; } #define LTT_TIME_MIN(a,b) ((ltt_time_compare((a),(b)) < 0) ? (a) : (b)) -- 2.34.1