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 |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "BitVector.h" | 27 #include "BitVector.h" |
28 | 28 |
29 #include <algorithm> | 29 #include <algorithm> |
30 #include <string.h> | 30 #include <string.h> |
31 #include "wtf/Assertions.h" | 31 #include "wtf/Assertions.h" |
32 #include "wtf/FastMalloc.h" | 32 #include "wtf/FastMalloc.h" |
33 #include "wtf/StdLibExtras.h" | 33 #include "wtf/StdLibExtras.h" |
(...skipping 13 matching lines...) Expand all Loading... |
47 if (!isInline()) | 47 if (!isInline()) |
48 OutOfLineBits::destroy(outOfLineBits()); | 48 OutOfLineBits::destroy(outOfLineBits()); |
49 m_bitsOrPointer = newBitsOrPointer; | 49 m_bitsOrPointer = newBitsOrPointer; |
50 } | 50 } |
51 | 51 |
52 void BitVector::resize(size_t numBits) | 52 void BitVector::resize(size_t numBits) |
53 { | 53 { |
54 if (numBits <= maxInlineBits()) { | 54 if (numBits <= maxInlineBits()) { |
55 if (isInline()) | 55 if (isInline()) |
56 return; | 56 return; |
57 | 57 |
58 OutOfLineBits* myOutOfLineBits = outOfLineBits(); | 58 OutOfLineBits* myOutOfLineBits = outOfLineBits(); |
59 m_bitsOrPointer = makeInlineBits(*myOutOfLineBits->bits()); | 59 m_bitsOrPointer = makeInlineBits(*myOutOfLineBits->bits()); |
60 OutOfLineBits::destroy(myOutOfLineBits); | 60 OutOfLineBits::destroy(myOutOfLineBits); |
61 return; | 61 return; |
62 } | 62 } |
63 | 63 |
64 resizeOutOfLine(numBits); | 64 resizeOutOfLine(numBits); |
65 } | 65 } |
66 | 66 |
67 void BitVector::clearAll() | 67 void BitVector::clearAll() |
68 { | 68 { |
69 if (isInline()) | 69 if (isInline()) |
70 m_bitsOrPointer = makeInlineBits(0); | 70 m_bitsOrPointer = makeInlineBits(0); |
71 else | 71 else |
72 memset(outOfLineBits()->bits(), 0, byteCount(size())); | 72 memset(outOfLineBits()->bits(), 0, byteCount(size())); |
73 } | 73 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 { | 110 { |
111 for (size_t i = 0; i < size(); ++i) { | 111 for (size_t i = 0; i < size(); ++i) { |
112 if (get(i)) | 112 if (get(i)) |
113 out.printf("1"); | 113 out.printf("1"); |
114 else | 114 else |
115 out.printf("-"); | 115 out.printf("-"); |
116 } | 116 } |
117 } | 117 } |
118 | 118 |
119 } // namespace WTF | 119 } // namespace WTF |
OLD | NEW |