From 85153d0f31c6dd60949b83f00872d63ff4b07e1f Mon Sep 17 00:00:00 2001 From: riccardom Date: Mon, 25 May 2009 19:46:29 +0000 Subject: [PATCH] Cleanup EmuLoop a bit: use an array instead of heap for the fps string and save a variable by moving zeroing of one with the very same value after we need it. --- desmume/src/gtk/main.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/desmume/src/gtk/main.cpp b/desmume/src/gtk/main.cpp index 423070626..a92e32e5f 100644 --- a/desmume/src/gtk/main.cpp +++ b/desmume/src/gtk/main.cpp @@ -1430,9 +1430,10 @@ static inline void _updateDTools() gboolean EmuLoop(gpointer data) { - static Uint32 fps, fps_SecStart, fps_FrameCount; + static Uint32 fps_SecStart, fps_FrameCount; + static int limiter_frame_counter; unsigned int i; - gchar *Title; + gchar Title[20]; if (!desmume_running()) { regMainLoop = FALSE; @@ -1440,18 +1441,16 @@ gboolean EmuLoop(gpointer data) } /* If desmume is currently running */ - static int limiter_frame_counter = 0; fps_FrameCount += Frameskip + 1; if (!fps_SecStart) fps_SecStart = SDL_GetTicks(); + if (SDL_GetTicks() - fps_SecStart >= 1000) { fps_SecStart = SDL_GetTicks(); - fps = fps_FrameCount; - fps_FrameCount = 0; - Title = g_strdup_printf("Desmume - %dfps", fps); + snprintf(Title, sizeof(Title), "Desmume - %dfps", fps_FrameCount); gtk_window_set_title(GTK_WINDOW(pWindow), Title); - g_free(Title); + fps_FrameCount = 0; } desmume_cycle(); /* Emule ! */