| 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 30 matching lines...) Expand all Loading... |
| 41 // number of bits. | 41 // number of bits. |
| 42 // | 42 // |
| 43 // - The bitvector remembers the bound of how many bits can be stored, but this | 43 // - The bitvector remembers the bound of how many bits can be stored, but this |
| 44 // may be slightly greater (by as much as some platform-specific constant) | 44 // may be slightly greater (by as much as some platform-specific constant) |
| 45 // than the last argument passed to ensureSize(). | 45 // than the last argument passed to ensureSize(). |
| 46 // | 46 // |
| 47 // - The bitvector can resize itself automatically (set, clear, get) or can be | 47 // - The bitvector can resize itself automatically (set, clear, get) or can be |
| 48 // used in a manual mode, which is faster (quickSet, quickClear, quickGet, | 48 // used in a manual mode, which is faster (quickSet, quickClear, quickGet, |
| 49 // ensureSize). | 49 // ensureSize). |
| 50 // | 50 // |
| 51 // - Accesses ASSERT that you are within bounds. | 51 // - Accesses assert that you are within bounds. |
| 52 // | 52 // |
| 53 // - Bits are automatically initialized to zero. | 53 // - Bits are automatically initialized to zero. |
| 54 // | 54 // |
| 55 // On the other hand, this BitVector class may not be the fastest around, since | 55 // On the other hand, this BitVector class may not be the fastest around, since |
| 56 // it does conditionals on every get/set/clear. But it is great if you need to | 56 // it does conditionals on every get/set/clear. But it is great if you need to |
| 57 // juggle a lot of variable-length BitVectors and you're worried about wasting | 57 // juggle a lot of variable-length BitVectors and you're worried about wasting |
| 58 // space. | 58 // space. |
| 59 | 59 |
| 60 class WTF_EXPORT BitVector { | 60 class WTF_EXPORT BitVector { |
| 61 DISALLOW_NEW(); | 61 DISALLOW_NEW(); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 void dump(PrintStream& out); | 159 void dump(PrintStream& out); |
| 160 | 160 |
| 161 private: | 161 private: |
| 162 static unsigned bitsInPointer() { return sizeof(void*) << 3; } | 162 static unsigned bitsInPointer() { return sizeof(void*) << 3; } |
| 163 | 163 |
| 164 static unsigned maxInlineBits() { return bitsInPointer() - 1; } | 164 static unsigned maxInlineBits() { return bitsInPointer() - 1; } |
| 165 | 165 |
| 166 static size_t byteCount(size_t bitCount) { return (bitCount + 7) >> 3; } | 166 static size_t byteCount(size_t bitCount) { return (bitCount + 7) >> 3; } |
| 167 | 167 |
| 168 static uintptr_t makeInlineBits(uintptr_t bits) { | 168 static uintptr_t makeInlineBits(uintptr_t bits) { |
| 169 ASSERT(!(bits & (static_cast<uintptr_t>(1) << maxInlineBits()))); | 169 DCHECK(!(bits & (static_cast<uintptr_t>(1) << maxInlineBits()))); |
| 170 return bits | (static_cast<uintptr_t>(1) << maxInlineBits()); | 170 return bits | (static_cast<uintptr_t>(1) << maxInlineBits()); |
| 171 } | 171 } |
| 172 | 172 |
| 173 class WTF_EXPORT OutOfLineBits { | 173 class WTF_EXPORT OutOfLineBits { |
| 174 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 174 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 175 | 175 |
| 176 public: | 176 public: |
| 177 size_t numBits() const { return m_numBits; } | 177 size_t numBits() const { return m_numBits; } |
| 178 size_t numWords() const { | 178 size_t numWords() const { |
| 179 return (m_numBits + bitsInPointer() - 1) / bitsInPointer(); | 179 return (m_numBits + bitsInPointer() - 1) / bitsInPointer(); |
| (...skipping 38 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 |