Replace uses of WTF::BitArray with std::bitset
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Dec 2013 18:31:47 +0000 (18:31 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Dec 2013 18:31:47 +0000 (18:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=125642

Reviewed by Anders Carlsson.

../WebCore:

* css/CSSParser.cpp:
(WebCore::filterProperties):
(WebCore::CSSParser::createStyleProperties):
* css/StyleProperties.cpp:
(WebCore::StyleProperties::asText):

../WTF:

* GNUmakefile.list.am:
* WTF.vcxproj/WTF.vcxproj:
* WTF.vcxproj/WTF.vcxproj.filters:
* WTF.xcodeproj/project.pbxproj:
* wtf/BitArray.h: Removed.
* wtf/CMakeLists.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@160492 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/GNUmakefile.list.am
Source/WTF/WTF.vcxproj/WTF.vcxproj
Source/WTF/WTF.vcxproj/WTF.vcxproj.filters
Source/WTF/WTF.xcodeproj/project.pbxproj
Source/WTF/wtf/BitArray.h [deleted file]
Source/WTF/wtf/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/StyleProperties.cpp

index 798925b..d2320b5 100644 (file)
@@ -1,3 +1,17 @@
+2013-12-12  Sam Weinig  <sam@webkit.org>
+
+        Replace uses of WTF::BitArray with std::bitset
+        https://bugs.webkit.org/show_bug.cgi?id=125642
+
+        Reviewed by Anders Carlsson.
+
+        * GNUmakefile.list.am:
+        * WTF.vcxproj/WTF.vcxproj:
+        * WTF.vcxproj/WTF.vcxproj.filters:
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/BitArray.h: Removed.
+        * wtf/CMakeLists.txt:
+
 2013-12-11  David Kilzer  <ddkilzer@apple.com>
 
         Define m_hasBadParent in InlineBox if defined(ADDRESS_SANITIZER)
index b18ef07..76490c7 100644 (file)
@@ -10,7 +10,6 @@ wtf_sources += \
     Source/WTF/wtf/AutodrainedPool.h \
     Source/WTF/wtf/Bag.h \
     Source/WTF/wtf/BagToHashMap.h \
-    Source/WTF/wtf/BitArray.h \
     Source/WTF/wtf/BitVector.cpp \
     Source/WTF/wtf/BitVector.h \
     Source/WTF/wtf/Bitmap.h \
index 1021852..c0a542b 100644 (file)
     <ClInclude Include="..\wtf\AVLTree.h" />
     <ClInclude Include="..\wtf\Bag.h" />
     <ClInclude Include="..\wtf\BagToHashMap.h" />
-    <ClInclude Include="..\wtf\BitArray.h" />
     <ClInclude Include="..\wtf\Bitmap.h" />
     <ClInclude Include="..\wtf\BitVector.h" />
     <ClInclude Include="..\wtf\BlockStack.h" />
index 01d5b7d..8f53efe 100644 (file)
     <ClInclude Include="..\wtf\AVLTree.h">
       <Filter>wtf</Filter>
     </ClInclude>
-    <ClInclude Include="..\wtf\BitArray.h">
-      <Filter>wtf</Filter>
-    </ClInclude>
     <ClInclude Include="..\wtf\Bitmap.h">
       <Filter>wtf</Filter>
     </ClInclude>
index 0a78f05..b462209 100644 (file)
@@ -65,7 +65,6 @@
                2CDED0F318115C85004DBA70 /* RunLoop.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2CDED0F118115C85004DBA70 /* RunLoop.cpp */; };
                2CDED0F418115C85004DBA70 /* RunLoop.h in Headers */ = {isa = PBXBuildFile; fileRef = 2CDED0F218115C85004DBA70 /* RunLoop.h */; };
                44F66008171AFAE600E4AD19 /* EnumClass.h in Headers */ = {isa = PBXBuildFile; fileRef = 44F66007171AFAA900E4AD19 /* EnumClass.h */; };
-               4F0321BC156AA8D1006EBAF6 /* BitArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F0321BB156AA8D1006EBAF6 /* BitArray.h */; };
                7E29C33E15FFD79B00516D61 /* ObjcRuntimeExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E29C33D15FFD79B00516D61 /* ObjcRuntimeExtras.h */; };
                8134013815B092FD001FF0B8 /* Base64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8134013615B092FD001FF0B8 /* Base64.cpp */; };
                8134013915B092FD001FF0B8 /* Base64.h in Headers */ = {isa = PBXBuildFile; fileRef = 8134013715B092FD001FF0B8 /* Base64.h */; };
                2CDED0F218115C85004DBA70 /* RunLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RunLoop.h; sourceTree = "<group>"; };
                44DEE74A152274BB00C6EC37 /* iOS.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = iOS.xcconfig; sourceTree = "<group>"; };
                44F66007171AFAA900E4AD19 /* EnumClass.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EnumClass.h; sourceTree = "<group>"; };
-               4F0321BB156AA8D1006EBAF6 /* BitArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BitArray.h; sourceTree = "<group>"; };
                5D247B6214689B8600E78B76 /* libWTF.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libWTF.a; sourceTree = BUILT_PRODUCTS_DIR; };
                5D247B6E14689C4700E78B76 /* Base.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = "<group>"; };
                5D247B7014689C4700E78B76 /* DebugRelease.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = DebugRelease.xcconfig; sourceTree = "<group>"; };
                                A8A4725E151A825A004123FF /* AVLTree.h */,
                                0FB14E18180FA218009B6B4D /* Bag.h */,
                                0FB14E1A1810E1DA009B6B4D /* BagToHashMap.h */,
-                               4F0321BB156AA8D1006EBAF6 /* BitArray.h */,
                                A8A4725F151A825A004123FF /* Bitmap.h */,
                                A8A47260151A825A004123FF /* BitVector.cpp */,
                                A8A47261151A825A004123FF /* BitVector.h */,
                                A8A473A9151A825B004123FF /* bignum-dtoa.h in Headers */,
                                A8A473AB151A825B004123FF /* bignum.h in Headers */,
                                A8A47452151A825B004123FF /* BinarySemaphore.h in Headers */,
-                               4F0321BC156AA8D1006EBAF6 /* BitArray.h in Headers */,
                                A8A4738A151A825B004123FF /* Bitmap.h in Headers */,
                                A8A4738C151A825B004123FF /* BitVector.h in Headers */,
                                A8A4738E151A825B004123FF /* BlockStack.h in Headers */,
diff --git a/Source/WTF/wtf/BitArray.h b/Source/WTF/wtf/BitArray.h
deleted file mode 100644 (file)
index 9ad1e0a..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#ifndef BitArray_h
-#define BitArray_h
-
-#include <string.h>
-#include <wtf/Assertions.h>
-
-namespace WTF {
-
-template<unsigned arraySize>
-class BitArray {
-public:
-    BitArray()
-    {
-        memset(m_data, 0, sizeof(m_data));
-    }
-
-    void set(unsigned index)
-    {
-        ASSERT_WITH_SECURITY_IMPLICATION(index < arraySize);
-        m_data[index / 8] |= 1 << (index & 7);
-    }
-
-    bool get(unsigned index) const
-    {
-        ASSERT_WITH_SECURITY_IMPLICATION(index < arraySize);
-        return !!(m_data[index / 8] & (1 << (index & 7)));
-    }
-
-private:
-    unsigned char m_data[arraySize / 8 + 1];
-};
-
-} // namespace WTF
-
-using WTF::BitArray;
-
-#endif // BitArray_h
index 5fdceb8..58e784c 100644 (file)
@@ -5,7 +5,6 @@ set(WTF_HEADERS
     Atomics.h
     Bag.h
     BagToHashMap.h
-    BitArray.h
     BitVector.h
     Bitmap.h
     BoundsCheckedPointer.h
index 28388bd..839e6c5 100644 (file)
@@ -1,3 +1,16 @@
+2013-12-12  Sam Weinig  <sam@webkit.org>
+
+        Replace uses of WTF::BitArray with std::bitset
+        https://bugs.webkit.org/show_bug.cgi?id=125642
+
+        Reviewed by Anders Carlsson.
+
+        * css/CSSParser.cpp:
+        (WebCore::filterProperties):
+        (WebCore::CSSParser::createStyleProperties):
+        * css/StyleProperties.cpp:
+        (WebCore::StyleProperties::asText):
+
 2013-12-12  Alexey Proskuryakov  <ap@apple.com>
 
         Make algorithm.name return registered name, not normalized one
index 9975e3a..93bcbcb 100644 (file)
@@ -84,8 +84,8 @@
 #include "WebKitCSSKeyframesRule.h"
 #include "WebKitCSSRegionRule.h"
 #include "WebKitCSSTransformValue.h"
+#include <bitset>
 #include <limits.h>
-#include <wtf/BitArray.h>
 #include <wtf/HexNumber.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/dtoa.h>
@@ -1479,7 +1479,7 @@ PassOwnPtr<MediaQuery> CSSParser::parseMediaQuery(const String& string)
     return m_mediaQuery.release();
 }
 
-static inline void filterProperties(bool important, const CSSParser::ParsedPropertyVector& input, Vector<CSSProperty, 256>& output, size_t& unusedEntries, BitArray<numCSSProperties>& seenProperties)
+static inline void filterProperties(bool important, const CSSParser::ParsedPropertyVector& input, Vector<CSSProperty, 256>& output, size_t& unusedEntries, std::bitset<numCSSProperties>& seenProperties)
 {
     // Add properties in reverse order so that highest priority definitions are reached first. Duplicate definitions can then be ignored when found.
     for (int i = input.size() - 1; i >= 0; --i) {
@@ -1487,7 +1487,7 @@ static inline void filterProperties(bool important, const CSSParser::ParsedPrope
         if (property.isImportant() != important)
             continue;
         const unsigned propertyIDIndex = property.id() - firstCSSProperty;
-        if (seenProperties.get(propertyIDIndex))
+        if (seenProperties.test(propertyIDIndex))
             continue;
         seenProperties.set(propertyIDIndex);
         output[--unusedEntries] = property;
@@ -1496,7 +1496,7 @@ static inline void filterProperties(bool important, const CSSParser::ParsedPrope
 
 PassRef<ImmutableStyleProperties> CSSParser::createStyleProperties()
 {
-    BitArray<numCSSProperties> seenProperties;
+    std::bitset<numCSSProperties> seenProperties;
     size_t unusedEntries = m_parsedProperties.size();
     Vector<CSSProperty, 256> results(unusedEntries);
 
index c681cf2..32a3afa 100644 (file)
@@ -32,7 +32,7 @@
 #include "PropertySetCSSStyleDeclaration.h"
 #include "StylePropertyShorthand.h"
 #include "StyleSheetContents.h"
-#include <wtf/BitArray.h>
+#include <bitset>
 #include <wtf/text/StringBuilder.h>
 
 #ifndef NDEBUG
@@ -779,8 +779,8 @@ String StyleProperties::asText() const
     int repeatXPropertyIndex = -1;
     int repeatYPropertyIndex = -1;
 
-    BitArray<numCSSProperties> shorthandPropertyUsed;
-    BitArray<numCSSProperties> shorthandPropertyAppeared;
+    std::bitset<numCSSProperties> shorthandPropertyUsed;
+    std::bitset<numCSSProperties> shorthandPropertyAppeared;
 
     unsigned size = propertyCount();
     unsigned numDecls = 0;
@@ -824,13 +824,13 @@ String StyleProperties::asText() const
                 borderFallbackShorthandProperty = CSSPropertyBorderColor;
 
             // FIXME: Deal with cases where only some of border-(top|right|bottom|left) are specified.
-            if (!shorthandPropertyAppeared.get(CSSPropertyBorder - firstCSSProperty)) {
+            if (!shorthandPropertyAppeared.test(CSSPropertyBorder - firstCSSProperty)) {
                 value = borderPropertyValue(ReturnNullOnUncommonValues);
                 if (value.isNull())
                     shorthandPropertyAppeared.set(CSSPropertyBorder - firstCSSProperty);
                 else
                     shorthandPropertyID = CSSPropertyBorder;
-            } else if (shorthandPropertyUsed.get(CSSPropertyBorder - firstCSSProperty))
+            } else if (shorthandPropertyUsed.test(CSSPropertyBorder - firstCSSProperty))
                 shorthandPropertyID = CSSPropertyBorder;
             if (!shorthandPropertyID)
                 shorthandPropertyID = borderFallbackShorthandProperty;
@@ -925,9 +925,9 @@ String StyleProperties::asText() const
 
         unsigned shortPropertyIndex = shorthandPropertyID - firstCSSProperty;
         if (shorthandPropertyID) {
-            if (shorthandPropertyUsed.get(shortPropertyIndex))
+            if (shorthandPropertyUsed.test(shortPropertyIndex))
                 continue;
-            if (!shorthandPropertyAppeared.get(shortPropertyIndex) && value.isNull())
+            if (!shorthandPropertyAppeared.test(shortPropertyIndex) && value.isNull())
                 value = getPropertyValue(shorthandPropertyID);
             shorthandPropertyAppeared.set(shortPropertyIndex);
         }