Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 6e8b379

Browse files
committed
Fix Issue 19280 - Remove unnecessary error checks in core.time.currSystemTick
QueryPerformanceCounter doesn't fail on Windows XP or later. https://msdn.microsoft.com/en-us/library/windows/desktop/ms644904(v=vs.85).aspx gettimeofday called with a valid timeval address and a null second parameter doesn't fail. http://pubs.opengroup.org/onlinepubs/9699919799/functions/gettimeofday.html clock_gettime called with a valid clock_id and a valid timespec address is in principle allowed to fail if the number of seconds doesn't fit in time_t, so even though no known implementation does this it is probably best to retain the error check at this time. http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html
1 parent a59c383 commit 6e8b379

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/core/time.d

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3344,10 +3344,8 @@ struct TickDuration
33443344
import core.internal.abort : abort;
33453345
version (Windows)
33463346
{
3347-
ulong ticks;
3348-
if (QueryPerformanceCounter(cast(long*)&ticks) == 0)
3349-
abort("Failed in QueryPerformanceCounter().");
3350-
3347+
ulong ticks = void;
3348+
QueryPerformanceCounter(cast(long*)&ticks);
33513349
return TickDuration(ticks);
33523350
}
33533351
else version (Darwin)
@@ -3356,10 +3354,8 @@ struct TickDuration
33563354
return TickDuration(cast(long)mach_absolute_time());
33573355
else
33583356
{
3359-
timeval tv;
3360-
if (gettimeofday(&tv, null) != 0)
3361-
abort("Failed in gettimeofday().");
3362-
3357+
timeval tv = void;
3358+
gettimeofday(&tv, null);
33633359
return TickDuration(tv.tv_sec * TickDuration.ticksPerSec +
33643360
tv.tv_usec * TickDuration.ticksPerSec / 1000 / 1000);
33653361
}
@@ -3377,10 +3373,8 @@ struct TickDuration
33773373
}
33783374
else
33793375
{
3380-
timeval tv;
3381-
if (gettimeofday(&tv, null) != 0)
3382-
abort("Failed in gettimeofday().");
3383-
3376+
timeval tv = void;
3377+
gettimeofday(&tv, null);
33843378
return TickDuration(tv.tv_sec * TickDuration.ticksPerSec +
33853379
tv.tv_usec * TickDuration.ticksPerSec / 1000 / 1000);
33863380
}

0 commit comments

Comments
 (0)