> On Dec. 19, 2014, 7:11 p.m., Dominic Hamon wrote: > > 3rdparty/libprocess/3rdparty/stout/include/stout/duration.hpp, line 93 > > <https://reviews.apache.org/r/29226/diff/1/?file=796956#file796956line93> > > > > tv_sec and tv_usec are the right types to use, just in case they're not > > long int on some platforms. > > Joris Van Remoortere wrote: > Where do you find these types? > I'm only familiar with them being long int (e.g. > http://www.gnu.org/software/libc/manual/html_node/Elapsed-Time.html) > I can re-write it to be type agnostic, but then we lose readability: > ``` > struct timeval tval; > tval.tv_sec = secs(); > tval.tv_usec = us() - (tval.tv_sec * MILLISECONDS); > return tval; > ``` > > Dominic Hamon wrote: > i think that's as readable. maybe even: > > struct timeval tval; > tval.tv_sec = secs(); > tval.tv_usec = us() - (secs() * MILLISECONDS); > return tval; > > given that duplicate calls to secs() are cheap and will almost certainly > be optimized out.
We'd have to cast the second secs() call to an integer for the math to be correct. Reusing tval.tv_sec doest that in a more readable way? - Joris ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/29226/#review65654 ----------------------------------------------------------- On Dec. 19, 2014, 12:20 a.m., Joris Van Remoortere wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/29226/ > ----------------------------------------------------------- > > (Updated Dec. 19, 2014, 12:20 a.m.) > > > Review request for mesos and Benjamin Hindman. > > > Repository: mesos-git > > > Description > ------- > > See Summary. > > > Diffs > ----- > > 3rdparty/libprocess/3rdparty/stout/include/stout/duration.hpp > f3447055eb5a0f6abf55211f337e062ed2cc607e > 3rdparty/libprocess/3rdparty/stout/tests/duration_tests.cpp > 4269d3c8964dce920beb8a40ef72caf075aa0a66 > > Diff: https://reviews.apache.org/r/29226/diff/ > > > Testing > ------- > > make check. > > > Thanks, > > Joris Van Remoortere > >