Chromium Code Reviews| Index: src/utils/SkBitSet.h |
| diff --git a/src/utils/SkBitSet.h b/src/utils/SkBitSet.h |
| index e113fd70044eb148302977ae70728565f6931426..f6adc5180697d302778698f3db3a53d84f7ed796 100644 |
| --- a/src/utils/SkBitSet.h |
| +++ b/src/utils/SkBitSet.h |
| @@ -30,11 +30,21 @@ public: |
| /** Set the value of the index-th bit. |
| */ |
| - void setBit(int index, bool value); |
| + void setBit(int index, bool value) { |
| + uint32_t mask = 1 << (index % 32); |
|
reed1
2014/10/09 15:53:43
nit: in skia using % 32 is far more rare than (ind
mtklein
2014/10/09 16:12:59
Done.
Generated code looks fine to me both ways,
|
| + if (value) { |
| + *(this->internalGet(index)) |= mask; |
|
reed1
2014/10/09 15:53:43
stylistic:
uint32_t mask = ...
uint32_t* chunk =
mtklein
2014/10/09 16:12:59
Done.
For what it's worth, it had better only cal
|
| + } else { |
| + *(this->internalGet(index)) &= ~mask; |
| + } |
| + } |
| /** Test if bit index is set. |
| */ |
| - bool isBitSet(int index) const; |
| + bool isBitSet(int index) const { |
| + uint32_t mask = 1 << (index % 32); |
| + return 0 != (*this->internalGet(index) & mask); |
|
reed1
2014/10/09 15:53:43
trivial nit: use SkToBool(...) instead?
mtklein
2014/10/09 16:12:59
Done.
|
| + } |
| /** Or bits from source. false is returned if this doesn't have the same |
| * bit count as source. |