Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Unified Diff: src/utils/SkBitSet.h

Issue 640243003: Small improvements to SkBitSet: (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/utils/SkBitSet.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « no previous file | src/utils/SkBitSet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698