]> gitweb.factorcode.org Git - factor.git/commitdiff
calendar.unix: inline some things.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 15 Aug 2012 15:29:00 +0000 (08:29 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 15 Aug 2012 15:29:46 +0000 (08:29 -0700)
basis/calendar/unix/unix.factor

index c02f836da84ebbfd0378b39be4104532aa259a16..f106f8810e4f42b0f70e57f0e7144a6957a7950a 100644 (file)
@@ -7,23 +7,26 @@ IN: calendar.unix
 : timeval>seconds ( timeval -- seconds )
     [ sec>> ] [ usec>> 1,000,000 / ] bi + ; inline
 
+: timeval>micros ( timeval -- micros )
+    [ sec>> 1,000,000 * ] [ usec>> ] bi + ; inline
+
 : timeval>duration ( timeval -- duration )
-    timeval>seconds seconds ;
+    timeval>seconds seconds ; inline
 
 : timeval>unix-time ( timeval -- timestamp )
-    [ unix-1970 ] dip timeval>seconds +second ;
+    [ unix-1970 ] dip timeval>seconds +second ; inline
 
 : timespec>seconds ( timespec -- seconds )
     [ sec>> ] [ nsec>> 1,000,000,000 / ] bi + ; inline
 
 : timespec>duration ( timespec -- duration )
-    timespec>seconds seconds ;
+    timespec>seconds seconds ; inline
 
 : timespec>unix-time ( timespec -- timestamp )
-    [ unix-1970 ] dip timespec>seconds +second ;
+    [ unix-1970 ] dip timespec>seconds +second ; inline
 
 : get-time ( -- alien )
-    f time time_t <ref> localtime ;
+    f time time_t <ref> localtime ; inline
 
 : timezone-name ( -- string )
     get-time zone>> ;
@@ -32,11 +35,10 @@ M: unix gmt-offset ( -- hours minutes seconds )
     get-time gmtoff>> 3600 /mod 60 /mod ;
 
 : current-timeval ( -- timeval )
-    timeval <struct> f [ gettimeofday io-error ] 2keep drop ;
+    timeval <struct> f [ gettimeofday io-error ] 2keep drop ; inline
 
 : system-micros ( -- n )
-    current-timeval
-    [ sec>> 1,000,000 * ] [ usec>> ] bi + ;
+    current-timeval timeval>micros ;
 
 M: unix gmt
     current-timeval timeval>unix-time ;