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

Side by Side Diff: src/utils/SkBitSet.h

Issue 2354583002: SkPDF: SkBitSet gets reset() to make drop() better. (Closed)
Patch Set: Created 4 years, 3 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 unified diff | Download patch
« src/pdf/SkPDFFont.cpp ('K') | « src/pdf/SkPDFFont.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkBitSet_DEFINED 8 #ifndef SkBitSet_DEFINED
9 #define SkBitSet_DEFINED 9 #define SkBitSet_DEFINED
10 10
11 #include "SkTDArray.h" 11 #include "SkTDArray.h"
12 #include "SkTemplates.h" 12 #include "SkTemplates.h"
13 13
14 class SkBitSet { 14 class SkBitSet {
15 public: 15 public:
16 explicit SkBitSet(int numberOfBits) { 16 explicit SkBitSet(int numberOfBits) {
17 SkASSERT(numberOfBits > 0); 17 SkASSERT(numberOfBits > 0);
18 fDwordCount = (numberOfBits + 31) / 32; // Round up size to 32-bit boun dary. 18 fDwordCount = (numberOfBits + 31) / 32; // Round up size to 32-bit boun dary.
19 fBitData.reset((uint32_t*)sk_calloc_throw(fDwordCount * sizeof(uint32_t) )); 19 fBitData.reset((uint32_t*)sk_calloc_throw(fDwordCount * sizeof(uint32_t) ));
20 } 20 }
21 21
22 SkBitSet(const SkBitSet&) = delete; 22 SkBitSet(const SkBitSet&) = delete;
23 SkBitSet& operator=(const SkBitSet&) = delete; 23 SkBitSet& operator=(const SkBitSet&) = delete;
24 24
25 void reset() {
26 fBitData = nullptr;
27 fDwordCount = 0;
bungeman-skia 2016/09/19 17:07:07 This seems a bit strange. Previous to this fDwordC
28 }
29
25 /** Set the value of the index-th bit to true. */ 30 /** Set the value of the index-th bit to true. */
26 void set(int index) { 31 void set(int index) {
27 uint32_t mask = 1 << (index & 31); 32 uint32_t mask = 1 << (index & 31);
28 uint32_t* chunk = this->internalGet(index); 33 uint32_t* chunk = this->internalGet(index);
29 SkASSERT(chunk); 34 SkASSERT(chunk);
30 *chunk |= mask; 35 *chunk |= mask;
31 } 36 }
32 37
33 template<typename T> 38 template<typename T>
34 void setAll(T* array, int len) { 39 void setAll(T* array, int len) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 size_t internalIndex = index / 32; 76 size_t internalIndex = index / 32;
72 if (internalIndex >= fDwordCount) { 77 if (internalIndex >= fDwordCount) {
73 return nullptr; 78 return nullptr;
74 } 79 }
75 return fBitData.get() + internalIndex; 80 return fBitData.get() + internalIndex;
76 } 81 }
77 }; 82 };
78 83
79 84
80 #endif 85 #endif
OLDNEW
« src/pdf/SkPDFFont.cpp ('K') | « src/pdf/SkPDFFont.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698