From 14422999243c3a569e86f8a50c2d690d46fa7381 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Wed, 29 Jan 2020 17:59:56 +0100 Subject: [PATCH] Made MixSounds be marked as hot Signed-off-by: Gabriel Ravier --- src/Backends/Audio/SDL2.cpp | 4 +++- src/CommonDefines.h | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Backends/Audio/SDL2.cpp b/src/Backends/Audio/SDL2.cpp index 64b3413b..55e9f97c 100644 --- a/src/Backends/Audio/SDL2.cpp +++ b/src/Backends/Audio/SDL2.cpp @@ -12,6 +12,7 @@ #include "../../Organya.h" #include "../../WindowsWrapper.h" +#include "../../CommonDefines.h" #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) @@ -70,7 +71,8 @@ static void SetSoundPan(AudioBackend_Sound *sound, long pan) sound->volume_r = sound->pan_r * sound->volume; } -static void MixSounds(float *stream, unsigned int frames_total) +// Most CPU-intensive function in the game (2/3rd CPU time consumption in my experience), so marked with attrHot so the compiler considers it a hot spot (as it is) when optimizing +attrHot static void MixSounds(float *stream, unsigned int frames_total) { for (AudioBackend_Sound *sound = sound_list_head; sound != NULL; sound = sound->next) { diff --git a/src/CommonDefines.h b/src/CommonDefines.h index 5b616ffb..9e458bdc 100644 --- a/src/CommonDefines.h +++ b/src/CommonDefines.h @@ -10,6 +10,10 @@ #define TILES_TO_UNITS(x) ((int)((x) * (0x200 * 0x10))) #define UNITS_TO_TILES(x) ((int)((x) / (0x200 * 0x10))) +#ifdef __GNUC__ +#define attrHot __attribute__((hot)) +#endif + enum Collisions { COLL_LEFT_WALL = 1, // Touching a left wall