commit 2362a641256c6f161fd56a6ba288fad4198390f2 parent 2aa6c2532a266b0a38063f249dc5625f62cef5d5 Author: Michael Savage <mikejsavage@gmail.com> Date: Sun Jan 17 23:23:26 +0000 Replace min_*/max_* with templates Diffstat:
gpubtt.cc | | | 4 | ++-- |
intrinsics.h | | | 10 | ++++------ |
diff --git a/gpubtt.cc b/gpubtt.cc @@ -57,7 +57,7 @@ void compute_horizons( ) { MEMARENA_SCOPED_CHECKPOINT( arena ); - const u32 max_hull_size = 2 * max_u32( hm->width, hm->height ); + const u32 max_hull_size = 2 * max( hm->width, hm->height ); glm::vec3 * hull = memarena_push_many( arena, glm::vec3, max_hull_size ); u32 hull_size = 1; @@ -74,7 +74,7 @@ void compute_horizons( hull_size--; } - const float horizon = max_f( 0.0, angle( p, hull[ hull_size - 1 ] ) ); + const float horizon = max( 0.0f, angle( p, hull[ hull_size - 1 ] ) ); horizons[ start.y * hm->width + start.x ] = horizon; hull[ hull_size ] = p; diff --git a/intrinsics.h b/intrinsics.h @@ -38,15 +38,13 @@ typedef double f64; #define megabytes( mb ) ( kilobytes( mb ) * size_t( 1024 ) ) #define gigabytes( gb ) ( megabytes( gb ) * size_t( 1024 ) ) -inline float max_f( float a, float b ) { - return a > b ? a : b; -} - -inline u32 min_u32( u32 a, u32 b ) { +template< typename T > +T min( T a, T b ) { return a < b ? a : b; } -inline u32 max_u32( u32 a, u32 b ) { +template< typename T > +T max( T a, T b ) { return a > b ? a : b; }