diff options
| author | flashback-fx <[email protected]> | 2022-06-07 21:01:29 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-06-07 21:01:29 +0200 |
| commit | 8c55b40e9ed52de00a73494e053af80057c126b6 (patch) | |
| tree | 5bf25320ac5499a82739e867dfcaa4abb10f7022 /src | |
| parent | ae715ba0d8c02dc6a6999fff6254b55101920478 (diff) | |
| download | raylib-8c55b40e9ed52de00a73494e053af80057c126b6.tar.gz raylib-8c55b40e9ed52de00a73494e053af80057c126b6.zip | |
Unify busy waiting behavior across conditional compilation branches (#2508)
* Unify busy waiting behavior across conditional compilation branches
* Inline busy waiting code instead of using static function
Diffstat (limited to 'src')
| -rw-r--r-- | src/rcore.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/rcore.c b/src/rcore.c index 932b9ee4..fa9fdf93 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -4826,15 +4826,14 @@ static void InitTimer(void) // Ref: http://www.geisswerks.com/ryan/FAQS/timing.html --> All about timming on Win32! void WaitTime(double seconds) { -#if defined(SUPPORT_BUSY_WAIT_LOOP) - double previousTime = GetTime(); - double currentTime = 0.0; +#if defined(SUPPORT_BUSY_WAIT_LOOP) || defined(SUPPORT_PARTIALBUSY_WAIT_LOOP) + double destinationTime = GetTime() + seconds; +#endif - // Busy wait loop - while ((currentTime - previousTime) < seconds) currentTime = GetTime(); +#if defined(SUPPORT_BUSY_WAIT_LOOP) + while (GetTime() < destinationTime) { } #else #if defined(SUPPORT_PARTIALBUSY_WAIT_LOOP) - double destinationTime = GetTime() + seconds; double sleepSeconds = seconds - seconds*0.05; // NOTE: We reserve a percentage of the time for busy waiting #else double sleepSeconds = seconds; |
