QueryPerformanceXXX does not fail after WindowsXP, simplify code.

This commit is contained in:
Ion Gaztañaga
2023-01-20 12:41:56 +01:00
parent 99294523dc
commit 2513f1bdcd

View File

@@ -103,10 +103,9 @@ struct QPFHolder
static inline double get_nsec_per_tic() static inline double get_nsec_per_tic()
{ {
long long freq; long long freq;
int r = boost::move_detail::QueryPerformanceFrequency( &freq ); //According to MS documentation:
boost::movelib::ignore(r); //"On systems that run Windows XP or later, the function will always succeed and will thus never return zero"
assert(r != 0 && "Boost::Move - get_nanosecs_per_tic Internal Error"); (void)boost::move_detail::QueryPerformanceFrequency(&freq);
return double(1000000000.0L / double(freq)); return double(1000000000.0L / double(freq));
} }
@@ -121,16 +120,9 @@ inline boost::uint64_t nsec_clock() BOOST_NOEXCEPT
double nanosecs_per_tic = QPFHolder<0>::nanosecs_per_tic; double nanosecs_per_tic = QPFHolder<0>::nanosecs_per_tic;
long long pcount; long long pcount;
unsigned times=0; //According to MS documentation:
while ( !boost::move_detail::QueryPerformanceCounter( &pcount ) ) //"On systems that run Windows XP or later, the function will always succeed and will thus never return zero"
{ (void)boost::move_detail::QueryPerformanceCounter( &pcount );
if ( ++times > 3 )
{
assert("Boost::Move - QueryPerformanceCounter Internal Error");
return 0u;
}
}
return static_cast<boost::uint64_t>(nanosecs_per_tic * double(pcount)); return static_cast<boost::uint64_t>(nanosecs_per_tic * double(pcount));
} }