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

Unified Diff: src/utils/SkBitSet.h

Issue 640243003: Small improvements to SkBitSet: (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: reed 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..266fd87496255ec1d2f9a528933ae0bbc32b96f3 100644
--- a/src/utils/SkBitSet.h
+++ b/src/utils/SkBitSet.h
@@ -30,11 +30,22 @@ 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 & 31);
+ uint32_t* chunk = this->internalGet(index);
+ if (value) {
+ *chunk |= mask;
+ } else {
+ *chunk &= ~mask;
+ }
+ }
/** Test if bit index is set.
*/
- bool isBitSet(int index) const;
+ bool isBitSet(int index) const {
+ uint32_t mask = 1 << (index & 31);
+ return SkToBool(*this->internalGet(index) & mask);
+ }
/** 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