Changeset - r7851:d007f368444a
[Not reviewed]
master
0 1 0
rubidium - 17 years ago 2007-11-10 23:22:32
rubidium@openttd.org
(svn r11401) -Fix [FS#1391]: make all min functions do exactly the same instead of branching on either < or <=.
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/macros.h
Show inline comments
 
@@ -111,39 +111,39 @@ template<typename T> static inline T min
 

	
 
/**
 
 * Returns the minimum of two integer.
 
 *
 
 * This function returns the smaller value of two given integers.
 
 *
 
 * @param a The first integer
 
 * @param b The second integer
 
 * @return The smaller value
 
 */
 
static inline int min(const int a, const int b)
 
{
 
	return a <= b ? a : b;
 
	return a < b ? a : b;
 
}
 

	
 
/**
 
 * Returns the minimum of two unsigned integers.
 
 *
 
 * This function returns the smaller value of two given unsigned integers.
 
 *
 
 * @param a The first unsigned integer
 
 * @param b The second unsigned integer
 
 * @return The smaller value
 
 */
 
static inline uint minu(const uint a, const uint b)
 
{
 
	return a <= b ? a : b;
 
	return a < b ? a : b;
 
}
 

	
 
/**
 
 * Clamp an integer between an interval.
 
 *
 
 * This function returns a value which is between the given interval of
 
 * min and max. If the given value is in this interval the value itself
 
 * is returned otherwise the border of the interval is returned, according
 
 * which side of the interval was 'left'.
 
 *
 
 * @note The min value must be less or equal of max or you get some
 
 *       unexpected results.
0 comments (0 inline, 0 general)