time add and sub performance tweaks
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Fri, 13 Aug 2004 18:33:22 +0000 (18:33 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Fri, 13 Aug 2004 18:33:22 +0000 (18:33 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@728 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/ltt/time.h

index e350cc998e8ae08ad5ac9527ddd670f971aaee37..ec4d134baf97d051ae2d3d7b87c29f837a5943b4 100644 (file)
@@ -40,12 +40,10 @@ static inline LttTime ltt_time_sub(LttTime t1, LttTime t2)
 {
   LttTime res;
   res.tv_sec  = t1.tv_sec  - t2.tv_sec;
+  res.tv_nsec = t1.tv_nsec - t2.tv_nsec;
   if(t1.tv_nsec < t2.tv_nsec) {
     res.tv_sec--;
-    res.tv_nsec = NANOSECONDS_PER_SECOND + t1.tv_nsec - t2.tv_nsec;
-  }
-  else {
-    res.tv_nsec = t1.tv_nsec - t2.tv_nsec;
+    res.tv_nsec += NANOSECONDS_PER_SECOND;
   }
   return res;
 }
@@ -54,8 +52,8 @@ static inline LttTime ltt_time_sub(LttTime t1, LttTime t2)
 static inline LttTime ltt_time_add(LttTime t1, LttTime t2) 
 {
   LttTime res;
-  res.tv_sec  = t1.tv_sec  + t2.tv_sec;
   res.tv_nsec = t1.tv_nsec + t2.tv_nsec;
+  res.tv_sec = t1.tv_sec + t2.tv_sec;
   if(res.tv_nsec >= NANOSECONDS_PER_SECOND) {
     res.tv_sec++;
     res.tv_nsec -= NANOSECONDS_PER_SECOND;
This page took 0.024023 seconds and 4 git commands to generate.