From 83c2d3ceef88c0565b1b2fb25792e28b9ba645a8 Mon Sep 17 00:00:00 2001 From: bjorn Date: Sun, 2 Jun 2019 01:47:44 -0700 Subject: [PATCH] Optimize timer module slightly; --- src/modules/timer/timer.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/modules/timer/timer.c b/src/modules/timer/timer.c index 37f7d25c..a9c89a7b 100644 --- a/src/modules/timer/timer.c +++ b/src/modules/timer/timer.c @@ -10,8 +10,6 @@ static struct { int tickIndex; double tickSum; double tickBuffer[TICK_SAMPLES]; - double averageDelta; - int fps; } state; bool lovrTimerInit() { @@ -40,8 +38,6 @@ double lovrTimerStep() { state.tickSum -= state.tickBuffer[state.tickIndex]; state.tickSum += state.dt; state.tickBuffer[state.tickIndex] = state.dt; - state.averageDelta = state.tickSum / TICK_SAMPLES; - state.fps = (int) (1 / (state.tickSum / TICK_SAMPLES) + .5); if (++state.tickIndex == TICK_SAMPLES) { state.tickIndex = 0; } @@ -49,11 +45,11 @@ double lovrTimerStep() { } double lovrTimerGetAverageDelta() { - return state.averageDelta; + return state.tickSum / TICK_SAMPLES; } int lovrTimerGetFPS() { - return state.fps; + return (int) (1 / (state.tickSum / TICK_SAMPLES) + .5); } void lovrTimerSleep(double seconds) {