summaryrefslogtreecommitdiff
path: root/src/helpers.hpp
diff options
context:
space:
mode:
authorKUDr <kudr@openttd.org>2007-02-23 20:51:10 +0000
committerKUDr <kudr@openttd.org>2007-02-23 20:51:10 +0000
commitdac3cd622f82c127fce8e57004e540c0eb6024a5 (patch)
tree6dc21c8c3b658f5fb2325b6c1f23ae7184195c99 /src/helpers.hpp
parent20405f56b4597de7591b297eaa4d8275217029b4 (diff)
downloadopenttd-dac3cd622f82c127fce8e57004e540c0eb6024a5.tar.xz
(svn r8864) -Codechange: make ClrBitT(), SetBitT() and ToggleBitT more like CLRBIT() and so on (modify value of the first parameter instead or returning the result)
Diffstat (limited to 'src/helpers.hpp')
-rw-r--r--src/helpers.hpp18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/helpers.hpp b/src/helpers.hpp
index 5f378803a..fb5aeb5f8 100644
--- a/src/helpers.hpp
+++ b/src/helpers.hpp
@@ -138,25 +138,19 @@ template <typename Tenum_t> struct TinyEnumT
}
};
-template <typename T> FORCEINLINE T ClrBitT(T t, int bit_index)
+template <typename T> void ClrBitT(T &t, int bit_index)
{
- int val = t;
- CLRBIT(val, bit_index);
- return (T)val;
+ t = (T)(t & ~((T)1 << bit_index));
}
-template <typename T> FORCEINLINE T SetBitT(T t, int bit_index)
+template <typename T> void SetBitT(T &t, int bit_index)
{
- int val = t;
- SETBIT(val, bit_index);
- return (T)val;
+ t = (T)(t | ((T)1 << bit_index));
}
-template <typename T> FORCEINLINE T ToggleBitT(T t, int bit_index)
+template <typename T> void ToggleBitT(T &t, int bit_index)
{
- int val = t;
- TOGGLEBIT(val, bit_index);
- return (T)val;
+ t = (T)(t ^ ((T)1 << bit_index));
}
#endif /* HELPERS_HPP */