Optimize avoiding CheckGameLoopTimerSkips

Implements a static boolean to track the CheckGameLoopTimerSkips preference, so that it isn't calling PREFSMAN via CheckGameLoopTimerSkips in a tight loop. Since this setting is rarely used, and isn't expected to be changed while the game is open, it doesn't need to be continuously checked.
This commit is contained in:
sukibaby
2024-09-06 11:31:46 -07:00
committed by teejusb
parent b698eb5f0c
commit 803dc1309a
+7 -4
View File
@@ -42,9 +42,6 @@ void GameLoop::SetUpdateRate( float fUpdateRate )
static void CheckGameLoopTimerSkips( float fDeltaTime )
{
if( !PREFSMAN->m_bLogSkips )
return;
static int iLastFPS = 0;
int iThisFPS = DISPLAY->GetFPS();
@@ -273,7 +270,13 @@ void GameLoop::UpdateAllButDraw(bool bRunningFromVBLANK)
? g_fConstantUpdateDeltaSeconds
: g_GameplayTimer.GetDeltaTime();
CheckGameLoopTimerSkips(fDeltaTime);
// Use a static boolean to check the preference once per game launch.
// This is a rarely used debug feature, so we try to skip it if possible.
static bool bLogSkips = PREFSMAN->m_bLogSkips;
if (bLogSkips)
{
CheckGameLoopTimerSkips(fDeltaTime);
}
fDeltaTime *= g_fUpdateRate;