minor optimization.
[platform/upstream/glib.git] / glib / gtimer.c
index 6850e58..d613a50 100644 (file)
@@ -184,9 +184,16 @@ g_timer_elapsed (GTimer *timer,
   elapsed.tv_sec = rtimer->end.tv_sec - rtimer->start.tv_sec;
 
   total = elapsed.tv_sec + ((gdouble) elapsed.tv_usec / 1e6);
+  if (total < 0)
+    {
+      total = 0;
 
-  if (microseconds)
+      if (microseconds)
+       *microseconds = 0;
+    }
+  else if (microseconds)
     *microseconds = elapsed.tv_usec;
+
 #endif /* !G_OS_WIN32 */
 
   return total;