From baf52ca21c4c7404380c5f6af97cf31a3d4f528d Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Thu, 2 Oct 2008 21:47:04 +0000 Subject: [PATCH] faster floating point comparison git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1726 0778d3d1-df1d-0410-868b-ea421aaaa00d --- include/types.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/types.h b/include/types.h index 2a2780f75..da3e6c5b0 100644 --- a/include/types.h +++ b/include/types.h @@ -60,6 +60,10 @@ typedef Sint8 fx_ch_t; // FX-channel (0 to MAX_EFFECT_CHANNEL) typedef Uint32 jo_id_t; // (unique) ID of a journalling object +// use for improved branch prediction +#define likely(x) __builtin_expect((x),1) +#define unlikely(x) __builtin_expect((x),0) + template struct typeInfo @@ -100,6 +104,10 @@ inline float typeInfo::minEps( void ) template<> inline bool typeInfo::isEqual( float _x, float _y ) { + if( likely( _x == _y ) ) + { + return true; + } return absVal( _x - _y ) < minEps(); } @@ -121,8 +129,4 @@ typedef sample_t sampleFrame[DEFAULT_CHANNELS]; typedef sample_t surroundSampleFrame[SURROUND_CHANNELS]; -// use for improved branch prediction -#define likely(x) __builtin_expect((x),1) -#define unlikely(x) __builtin_expect((x),0) - #endif