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

Unified Diff: src/utils/SkBitSet.cpp

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 | « src/utils/SkBitSet.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkBitSet.cpp
diff --git a/src/utils/SkBitSet.cpp b/src/utils/SkBitSet.cpp
index 36ff6cbb01c8afcb20ad2043e12b3a53ceca82c7..63d18ff2f3d4593e3c34d4fcf147e37d68eace10 100755
--- a/src/utils/SkBitSet.cpp
+++ b/src/utils/SkBitSet.cpp
@@ -14,8 +14,7 @@ SkBitSet::SkBitSet(int numberOfBits)
SkASSERT(numberOfBits > 0);
// Round up size to 32-bit boundary.
fDwordCount = (numberOfBits + 31) / 32;
- fBitData.set(malloc(fDwordCount * sizeof(uint32_t)));
- clearAll();
+ fBitData.set(sk_calloc_throw(fDwordCount * sizeof(uint32_t)));
}
SkBitSet::SkBitSet(const SkBitSet& source)
@@ -30,7 +29,7 @@ SkBitSet& SkBitSet::operator=(const SkBitSet& rhs) {
fBitCount = rhs.fBitCount;
fBitData.free();
fDwordCount = rhs.fDwordCount;
- fBitData.set(malloc(fDwordCount * sizeof(uint32_t)));
+ fBitData.set(sk_malloc_throw(fDwordCount * sizeof(uint32_t)));
memcpy(fBitData.get(), rhs.fBitData.get(), fDwordCount * sizeof(uint32_t));
return *this;
}
@@ -56,25 +55,11 @@ void SkBitSet::clearAll() {
}
}
-void SkBitSet::setBit(int index, bool value) {
- uint32_t mask = 1 << (index % 32);
- if (value) {
- *(internalGet(index)) |= mask;
- } else {
- *(internalGet(index)) &= ~mask;
- }
-}
-
-bool SkBitSet::isBitSet(int index) const {
- uint32_t mask = 1 << (index % 32);
- return 0 != (*internalGet(index) & mask);
-}
-
bool SkBitSet::orBits(const SkBitSet& source) {
if (fBitCount != source.fBitCount) {
return false;
}
- uint32_t* targetBitmap = internalGet(0);
+ uint32_t* targetBitmap = this->internalGet(0);
uint32_t* sourceBitmap = source.internalGet(0);
for (size_t i = 0; i < fDwordCount; ++i) {
targetBitmap[i] |= sourceBitmap[i];
« no previous file with comments | « src/utils/SkBitSet.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698