diff options
author | Jacques Lucke <jacques@blender.org> | 2020-06-09 11:10:56 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-06-09 11:15:43 +0300 |
commit | d8678e02ecec9375bec1dcf1388c6fc8b4ce3ad2 (patch) | |
tree | 6e7d2a7452091877f73d413d830e6cb12e86745f /source/blender/blenlib/intern/math_bits_inline.c | |
parent | 50258d55e7c1360274d40e303386cf70b16c8b2f (diff) |
BLI: generally improve C++ data structures
The main focus here was to improve the docs significantly. Furthermore,
I reimplemented `Set`, `Map` and `VectorSet`. They are now (usually)
faster, simpler and more customizable. I also rewrote `Stack` to make
it more efficient by avoiding unnecessary copies.
Thanks to everyone who helped with constructive feedback.
Approved by brecht and sybren.
Differential Revision: https://developer.blender.org/D7931
Diffstat (limited to 'source/blender/blenlib/intern/math_bits_inline.c')
-rw-r--r-- | source/blender/blenlib/intern/math_bits_inline.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/source/blender/blenlib/intern/math_bits_inline.c b/source/blender/blenlib/intern/math_bits_inline.c index a6883c2aaba..8f8f257f1e7 100644 --- a/source/blender/blenlib/intern/math_bits_inline.c +++ b/source/blender/blenlib/intern/math_bits_inline.c @@ -77,8 +77,7 @@ MINLINE int bitscan_reverse_i(int a) MINLINE unsigned int bitscan_reverse_clear_uint(unsigned int *a) { unsigned int i = bitscan_reverse_uint(*a); - /* TODO(sergey): This could probably be optimized. */ - *a &= ~(1 << (sizeof(unsigned int) * 8 - i - 1)); + *a &= ~(0x80000000 >> i); return i; } @@ -97,10 +96,10 @@ MINLINE unsigned int highest_order_bit_uint(unsigned int n) MINLINE unsigned short highest_order_bit_s(unsigned short n) { - n |= (n >> 1); - n |= (n >> 2); - n |= (n >> 4); - n |= (n >> 8); + n |= (unsigned short)(n >> 1); + n |= (unsigned short)(n >> 2); + n |= (unsigned short)(n >> 4); + n |= (unsigned short)(n >> 8); return (unsigned short)(n - (n >> 1)); } |