OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 return; | 96 return; |
97 resizeOutOfLine(numBits); | 97 resizeOutOfLine(numBits); |
98 } | 98 } |
99 | 99 |
100 // Like ensureSize(), but supports reducing the size of the bitvector. | 100 // Like ensureSize(), but supports reducing the size of the bitvector. |
101 void resize(size_t numBits); | 101 void resize(size_t numBits); |
102 | 102 |
103 void clearAll(); | 103 void clearAll(); |
104 | 104 |
105 bool quickGet(size_t bit) const { | 105 bool quickGet(size_t bit) const { |
106 SECURITY_DCHECK(bit < size()); | 106 SECURITY_CHECK(bit < size()); |
107 return !!(bits()[bit / bitsInPointer()] & | 107 return !!(bits()[bit / bitsInPointer()] & |
108 (static_cast<uintptr_t>(1) << (bit & (bitsInPointer() - 1)))); | 108 (static_cast<uintptr_t>(1) << (bit & (bitsInPointer() - 1)))); |
109 } | 109 } |
110 | 110 |
111 void quickSet(size_t bit) { | 111 void quickSet(size_t bit) { |
112 SECURITY_DCHECK(bit < size()); | 112 SECURITY_CHECK(bit < size()); |
113 bits()[bit / bitsInPointer()] |= | 113 bits()[bit / bitsInPointer()] |= |
114 (static_cast<uintptr_t>(1) << (bit & (bitsInPointer() - 1))); | 114 (static_cast<uintptr_t>(1) << (bit & (bitsInPointer() - 1))); |
115 } | 115 } |
116 | 116 |
117 void quickClear(size_t bit) { | 117 void quickClear(size_t bit) { |
118 SECURITY_DCHECK(bit < size()); | 118 SECURITY_CHECK(bit < size()); |
119 bits()[bit / bitsInPointer()] &= | 119 bits()[bit / bitsInPointer()] &= |
120 ~(static_cast<uintptr_t>(1) << (bit & (bitsInPointer() - 1))); | 120 ~(static_cast<uintptr_t>(1) << (bit & (bitsInPointer() - 1))); |
121 } | 121 } |
122 | 122 |
123 void quickSet(size_t bit, bool value) { | 123 void quickSet(size_t bit, bool value) { |
124 if (value) | 124 if (value) |
125 quickSet(bit); | 125 quickSet(bit); |
126 else | 126 else |
127 quickClear(bit); | 127 quickClear(bit); |
128 } | 128 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 } | 218 } |
219 | 219 |
220 uintptr_t m_bitsOrPointer; | 220 uintptr_t m_bitsOrPointer; |
221 }; | 221 }; |
222 | 222 |
223 } // namespace WTF | 223 } // namespace WTF |
224 | 224 |
225 using WTF::BitVector; | 225 using WTF::BitVector; |
226 | 226 |
227 #endif // BitVector_h | 227 #endif // BitVector_h |
OLD | NEW |