Title: [217860] trunk/Source
Revision
217860
Author
[email protected]
Date
2017-06-06 15:09:44 -0700 (Tue, 06 Jun 2017)

Log Message

Cut down use of WTF_ARRAY_LENGTH
https://bugs.webkit.org/show_bug.cgi?id=172997

Reviewed by Chris Dumez.

Source/_javascript_Core:

* parser/Lexer.cpp:
(JSC::singleEscape): Use WTF_ARRAY_LENGTH instead of ARRAY_SIZE.

* runtime/NumberPrototype.cpp:
(JSC::toStringWithRadix): Use std::end instead of WTF_ARRAY_LENGTH.

Source/WebCore:

* contentextensions/NFAToDFA.cpp: Remove unused SetTransitions class.

* dom/Document.cpp:
(WebCore::Document::~Document): Use modern for loop instead of WTF_ARRAY_LENGTH.
* dom/make_names.pl:
(printDefinitions): Ditto.
(printFactoryCppFile): Ditto.
(printWrapperFactoryCppFile): Ditto.

* platform/URL.cpp:
(WebCore::portAllowed): Use std::is_sorted, std::begin, and std::end
in sort assertion to greatly streamline it and eliminate use of WTF_ARRAY_LENGTH.
Also allow the sort assertion to run every time; slightly optimizing debug builds
was not worth having the code be messy.

* platform/URLParser.cpp:
(WebCore::URLParser::appendNumberToASCIIBuffer): Use std::end instead of
WTF_ARRAY_LENGTH.

* platform/graphics/FontCascade.cpp: Make fontFamiliesWithInvalidCharWidth be
a constant array rather than a non-constant array to constant strings.
(WebCore::FontCascade::hasValidAverageCharWidth): Streamline the hash table
initialization to avoid heap allocation and use a modern for loop instead of
WTF_ARRAY_LENGTH.

* platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
(WebCore::disableComponentsOnce): Use a modern for loop instead of WTF_ARRAY_LENGTH.
* platform/network/CacheValidation.cpp:
(WebCore::shouldUpdateHeaderAfterRevalidation): Ditto. Also use the
startsWithIgnoringASCIICase function rather than the version that folds
arbitrary Unicode case.

* platform/text/TextEncodingRegistry.cpp:
(WebCore::pruneBlacklistedCodecs): Use modern for loops to make the code considerably
easier to read and avoid WTF_ARRAY_LENGTH.

* platform/text/mac/LocaleMac.mm:
(WebCore::LocaleMac::monthLabels): Use modern for loop instead of WTF_ARRAY_LENGTH.
(WebCore::LocaleMac::shortMonthLabels): Ditto.
* rendering/RenderCombineText.cpp:
(WebCore::RenderCombineText::combineText): Ditto.

Source/WTF:

* wtf/DateMath.cpp:
(WTF::equalLettersIgnoringASCIICase): Added helper function template.
(WTF::parseDateFromNullTerminatedCharacters): Use a modern for loop instead of
WTF_ARRAY_LENGTH. Use startsWithLettersIgnoringASCIICase and
equalLettersIgnoringASCIICase instead of strncasecmp.

* wtf/text/IntegerToStringConversion.h:
(WTF::numberToStringImpl): Use std::end instead of WTF_ARRAY_LENGTH.
(WTF::writeNumberToBufferImpl): Ditto.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (217859 => 217860)


--- trunk/Source/_javascript_Core/ChangeLog	2017-06-06 22:04:19 UTC (rev 217859)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-06-06 22:09:44 UTC (rev 217860)
@@ -1,3 +1,16 @@
+2017-06-06  Darin Adler  <[email protected]>
+
+        Cut down use of WTF_ARRAY_LENGTH
+        https://bugs.webkit.org/show_bug.cgi?id=172997
+
+        Reviewed by Chris Dumez.
+
+        * parser/Lexer.cpp:
+        (JSC::singleEscape): Use WTF_ARRAY_LENGTH instead of ARRAY_SIZE.
+
+        * runtime/NumberPrototype.cpp:
+        (JSC::toStringWithRadix): Use std::end instead of WTF_ARRAY_LENGTH.
+
 2017-06-06  Konstantin Tokarev  <[email protected]>
 
         Add missing <functional> includes

Modified: trunk/Source/_javascript_Core/parser/Lexer.cpp (217859 => 217860)


--- trunk/Source/_javascript_Core/parser/Lexer.cpp	2017-06-06 22:04:19 UTC (rev 217859)
+++ trunk/Source/_javascript_Core/parser/Lexer.cpp	2017-06-06 22:09:44 UTC (rev 217860)
@@ -827,7 +827,7 @@
 static inline LChar singleEscape(int c)
 {
     if (c < 128) {
-        ASSERT(static_cast<size_t>(c) < ARRAY_SIZE(singleCharacterEscapeValuesForASCII));
+        ASSERT(static_cast<size_t>(c) < WTF_ARRAY_LENGTH(singleCharacterEscapeValuesForASCII));
         return singleCharacterEscapeValuesForASCII[c];
     }
     return 0;

Modified: trunk/Source/_javascript_Core/runtime/NumberPrototype.cpp (217859 => 217860)


--- trunk/Source/_javascript_Core/runtime/NumberPrototype.cpp	2017-06-06 22:04:19 UTC (rev 217859)
+++ trunk/Source/_javascript_Core/runtime/NumberPrototype.cpp	2017-06-06 22:09:44 UTC (rev 217860)
@@ -362,7 +362,7 @@
 static String toStringWithRadix(int32_t number, unsigned radix)
 {
     LChar buf[1 + 32]; // Worst case is radix == 2, which gives us 32 digits + sign.
-    LChar* end = buf + WTF_ARRAY_LENGTH(buf);
+    LChar* end = std::end(buf);
     LChar* p = end;
 
     bool negative = false;

Modified: trunk/Source/WTF/ChangeLog (217859 => 217860)


--- trunk/Source/WTF/ChangeLog	2017-06-06 22:04:19 UTC (rev 217859)
+++ trunk/Source/WTF/ChangeLog	2017-06-06 22:09:44 UTC (rev 217860)
@@ -1,3 +1,20 @@
+2017-06-06  Darin Adler  <[email protected]>
+
+        Cut down use of WTF_ARRAY_LENGTH
+        https://bugs.webkit.org/show_bug.cgi?id=172997
+
+        Reviewed by Chris Dumez.
+
+        * wtf/DateMath.cpp:
+        (WTF::equalLettersIgnoringASCIICase): Added helper function template.
+        (WTF::parseDateFromNullTerminatedCharacters): Use a modern for loop instead of
+        WTF_ARRAY_LENGTH. Use startsWithLettersIgnoringASCIICase and
+        equalLettersIgnoringASCIICase instead of strncasecmp.
+
+        * wtf/text/IntegerToStringConversion.h:
+        (WTF::numberToStringImpl): Use std::end instead of WTF_ARRAY_LENGTH.
+        (WTF::writeNumberToBufferImpl): Ditto.
+
 2017-06-06  Filip Pizlo  <[email protected]>
 
         index out of bound in bytecodebasicblock

Modified: trunk/Source/WTF/wtf/DateMath.cpp (217859 => 217860)


--- trunk/Source/WTF/wtf/DateMath.cpp	2017-06-06 22:04:19 UTC (rev 217859)
+++ trunk/Source/WTF/wtf/DateMath.cpp	2017-06-06 22:09:44 UTC (rev 217860)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 1999-2000 Harri Porten ([email protected])
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
  * Copyright (C) 2009 Google Inc. All rights reserved.
  * Copyright (C) 2007-2009 Torch Mobile, Inc.
  * Copyright (C) 2010 &yet, LLC. ([email protected])
@@ -102,10 +102,14 @@
 #include <sys/timeb.h>
 #endif
 
-using namespace WTF;
-
 namespace WTF {
 
+// FIXME: Should this function go into StringCommon.h or some other header?
+template<unsigned length> inline bool startsWithLettersIgnoringASCIICase(const char* string, const char (&lowercaseLetters)[length])
+{
+    return equalLettersIgnoringASCIICase(string, lowercaseLetters, length - 1);
+}
+
 /* Constants */
 
 static const double maxUnixTime = 2145859200.0; // 12/31/2037
@@ -574,17 +578,17 @@
 #endif
         char tzName[4];
     int tzOffset;
-} known_zones[] = {
-    { "UT", 0 },
-    { "GMT", 0 },
-    { "EST", -300 },
-    { "EDT", -240 },
-    { "CST", -360 },
-    { "CDT", -300 },
-    { "MST", -420 },
-    { "MDT", -360 },
-    { "PST", -480 },
-    { "PDT", -420 }
+} knownZones[] = {
+    { "ut", 0 },
+    { "gmt", 0 },
+    { "est", -300 },
+    { "edt", -240 },
+    { "cst", -360 },
+    { "cdt", -300 },
+    { "mst", -420 },
+    { "mdt", -360 },
+    { "pst", -480 },
+    { "pdt", -420 }
 };
 
 inline static void skipSpacesAndComments(const char*& s)
@@ -1028,7 +1032,7 @@
 
             skipSpacesAndComments(dateString);
 
-            if (strncasecmp(dateString, "AM", 2) == 0) {
+            if (startsWithLettersIgnoringASCIICase(dateString, "am")) {
                 if (hour > 12)
                     return std::numeric_limits<double>::quiet_NaN();
                 if (hour == 12)
@@ -1035,7 +1039,7 @@
                     hour = 0;
                 dateString += 2;
                 skipSpacesAndComments(dateString);
-            } else if (strncasecmp(dateString, "PM", 2) == 0) {
+            } else if (startsWithLettersIgnoringASCIICase(dateString, "pm")) {
                 if (hour > 12)
                     return std::numeric_limits<double>::quiet_NaN();
                 if (hour != 12)
@@ -1059,7 +1063,7 @@
     // Don't fail if the time zone is missing. 
     // Some websites omit the time zone (4275206).
     if (*dateString) {
-        if (strncasecmp(dateString, "GMT", 3) == 0 || strncasecmp(dateString, "UTC", 3) == 0) {
+        if (startsWithLettersIgnoringASCIICase(dateString, "gmt") || startsWithLettersIgnoringASCIICase(dateString, "utc")) {
             dateString += 3;
             haveTZ = true;
         }
@@ -1090,10 +1094,13 @@
             }
             haveTZ = true;
         } else {
-            for (size_t i = 0; i < WTF_ARRAY_LENGTH(known_zones); ++i) {
-                if (0 == strncasecmp(dateString, known_zones[i].tzName, strlen(known_zones[i].tzName))) {
-                    offset = known_zones[i].tzOffset;
-                    dateString += strlen(known_zones[i].tzName);
+            for (auto& knownZone : knownZones) {
+                // Since the passed-in length is used for both strings, the following checks that
+                // dateString has the time zone name as a prefix, not that it is equal.
+                auto length = strlen(knownZone.tzName);
+                if (equalLettersIgnoringASCIICase(dateString, knownZone.tzName, length)) {
+                    offset = knownZone.tzOffset;
+                    dateString += length;
                     haveTZ = true;
                     break;
                 }

Modified: trunk/Source/WTF/wtf/text/IntegerToStringConversion.h (217859 => 217860)


--- trunk/Source/WTF/wtf/text/IntegerToStringConversion.h	2017-06-06 22:04:19 UTC (rev 217859)
+++ trunk/Source/WTF/wtf/text/IntegerToStringConversion.h	2017-06-06 22:09:44 UTC (rev 217860)
@@ -35,7 +35,7 @@
 static typename IntegerToStringConversionTrait<T>::ReturnType numberToStringImpl(UnsignedIntegerType number, AdditionalArgumentType additionalArgument)
 {
     LChar buf[sizeof(UnsignedIntegerType) * 3 + 1];
-    LChar* end = buf + WTF_ARRAY_LENGTH(buf);
+    LChar* end = std::end(buf);
     LChar* p = end;
 
     do {
@@ -68,7 +68,7 @@
 static void writeNumberToBufferImpl(UnsignedIntegerType number, CharacterType* destination)
 {
     LChar buf[sizeof(UnsignedIntegerType) * 3 + 1];
-    LChar* end = buf + WTF_ARRAY_LENGTH(buf);
+    LChar* end = std::end(buf);
     LChar* p = end;
 
     do {

Modified: trunk/Source/WebCore/ChangeLog (217859 => 217860)


--- trunk/Source/WebCore/ChangeLog	2017-06-06 22:04:19 UTC (rev 217859)
+++ trunk/Source/WebCore/ChangeLog	2017-06-06 22:09:44 UTC (rev 217860)
@@ -1,3 +1,52 @@
+2017-06-06  Darin Adler  <[email protected]>
+
+        Cut down use of WTF_ARRAY_LENGTH
+        https://bugs.webkit.org/show_bug.cgi?id=172997
+
+        Reviewed by Chris Dumez.
+
+        * contentextensions/NFAToDFA.cpp: Remove unused SetTransitions class.
+
+        * dom/Document.cpp:
+        (WebCore::Document::~Document): Use modern for loop instead of WTF_ARRAY_LENGTH.
+        * dom/make_names.pl:
+        (printDefinitions): Ditto.
+        (printFactoryCppFile): Ditto.
+        (printWrapperFactoryCppFile): Ditto.
+
+        * platform/URL.cpp:
+        (WebCore::portAllowed): Use std::is_sorted, std::begin, and std::end
+        in sort assertion to greatly streamline it and eliminate use of WTF_ARRAY_LENGTH.
+        Also allow the sort assertion to run every time; slightly optimizing debug builds
+        was not worth having the code be messy.
+
+        * platform/URLParser.cpp:
+        (WebCore::URLParser::appendNumberToASCIIBuffer): Use std::end instead of
+        WTF_ARRAY_LENGTH.
+
+        * platform/graphics/FontCascade.cpp: Make fontFamiliesWithInvalidCharWidth be
+        a constant array rather than a non-constant array to constant strings.
+        (WebCore::FontCascade::hasValidAverageCharWidth): Streamline the hash table
+        initialization to avoid heap allocation and use a modern for loop instead of
+        WTF_ARRAY_LENGTH.
+
+        * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
+        (WebCore::disableComponentsOnce): Use a modern for loop instead of WTF_ARRAY_LENGTH.
+        * platform/network/CacheValidation.cpp:
+        (WebCore::shouldUpdateHeaderAfterRevalidation): Ditto. Also use the
+        startsWithIgnoringASCIICase function rather than the version that folds
+        arbitrary Unicode case.
+
+        * platform/text/TextEncodingRegistry.cpp:
+        (WebCore::pruneBlacklistedCodecs): Use modern for loops to make the code considerably
+        easier to read and avoid WTF_ARRAY_LENGTH.
+
+        * platform/text/mac/LocaleMac.mm:
+        (WebCore::LocaleMac::monthLabels): Use modern for loop instead of WTF_ARRAY_LENGTH.
+        (WebCore::LocaleMac::shortMonthLabels): Ditto.
+        * rendering/RenderCombineText.cpp:
+        (WebCore::RenderCombineText::combineText): Ditto.
+
 2017-06-06  Isaac Devine  <[email protected]>
 
         Allow FileReader to open files multiple times

Modified: trunk/Source/WebCore/contentextensions/NFAToDFA.cpp (217859 => 217860)


--- trunk/Source/WebCore/contentextensions/NFAToDFA.cpp	2017-06-06 22:04:19 UTC (rev 217859)
+++ trunk/Source/WebCore/contentextensions/NFAToDFA.cpp	2017-06-06 22:09:44 UTC (rev 217860)
@@ -271,33 +271,6 @@
     }
 };
 
-class SetTransitions {
-public:
-    NodeIdSet& operator[](unsigned index)
-    {
-        ASSERT(index < size());
-        return m_targets[index];
-    }
-
-    unsigned size() const
-    {
-        return WTF_ARRAY_LENGTH(m_targets);
-    }
-
-    NodeIdSet* begin()
-    {
-        return m_targets;
-    }
-
-    NodeIdSet* end()
-    {
-        return m_targets + size();
-    }
-
-private:
-    NodeIdSet m_targets[128];
-};
-
 struct DataConverterWithEpsilonClosure {
     const NFANodeClosures& nfaNodeclosures;
 

Modified: trunk/Source/WebCore/dom/Document.cpp (217859 => 217860)


--- trunk/Source/WebCore/dom/Document.cpp	2017-06-06 22:04:19 UTC (rev 217859)
+++ trunk/Source/WebCore/dom/Document.cpp	2017-06-06 22:09:44 UTC (rev 217860)
@@ -616,11 +616,11 @@
     if (hasRareData())
         clearRareData();
 
-    ASSERT(!m_listsInvalidatedAtDocument.size());
-    ASSERT(!m_collectionsInvalidatedAtDocument.size());
+    ASSERT(m_listsInvalidatedAtDocument.isEmpty());
+    ASSERT(m_collectionsInvalidatedAtDocument.isEmpty());
 
-    for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_nodeListAndCollectionCounts); ++i)
-        ASSERT(!m_nodeListAndCollectionCounts[i]);
+    for (unsigned count : m_nodeListAndCollectionCounts)
+        ASSERT_UNUSED(count, !count);
 }
 
 void Document::removedLastRef()

Modified: trunk/Source/WebCore/dom/make_names.pl (217859 => 217860)


--- trunk/Source/WebCore/dom/make_names.pl	2017-06-06 22:04:19 UTC (rev 217859)
+++ trunk/Source/WebCore/dom/make_names.pl	2017-06-06 22:09:44 UTC (rev 217860)
@@ -918,13 +918,13 @@
 print F <<END
     };
 
-    for (unsigned i = 0; i < WTF_ARRAY_LENGTH(${type}Table); ++i)
+    for (auto& entry : ${type}Table)
 END
 ;
     if ($namespaceURI eq "nullAtom") {
-        print F "        createQualifiedName(${type}Table[i].targetAddress, &${type}Table[i].name);\n";
+        print F "        createQualifiedName(entry.targetAddress, &entry.name);\n";
     } else {
-        print F "        createQualifiedName(${type}Table[i].targetAddress, &${type}Table[i].name, $namespaceURI);\n";
+        print F "        createQualifiedName(entry.targetAddress, &entry.name, $namespaceURI);\n";
     }
 }
 
@@ -1024,11 +1024,10 @@
     print F <<END
     };
 
-    for (unsigned i = 0; i < WTF_ARRAY_LENGTH(table); ++i)
-        map.add(table[i].name.localName().impl(), ConstructorFunctionMapEntry(table[i].function, table[i].name));
+    for (auto& entry : table)
+        map.add(entry.name.localName().impl(), ConstructorFunctionMapEntry(entry.function, entry.name));
 }
 
-
 static ConstructorFunctionMapEntry find$parameters{namespace}ElementConstructorFunction(const AtomicString& localName)
 {
     static NeverDestroyed<HashMap<AtomicStringImpl*, ConstructorFunctionMapEntry>> map;
@@ -1306,8 +1305,8 @@
     print F <<END
     };
 
-    for (unsigned i = 0; i < WTF_ARRAY_LENGTH(table); ++i)
-        map.add(table[i].name.localName().impl(), table[i].function);
+    for (auto& entry : table)
+        map.add(entry.name.localName().impl(), entry.function);
 }
 
 JSDOMObject* createJS$parameters{namespace}Wrapper(JSDOMGlobalObject* globalObject, Ref<$parameters{namespace}Element>&& element)

Modified: trunk/Source/WebCore/platform/URL.cpp (217859 => 217860)


--- trunk/Source/WebCore/platform/URL.cpp	2017-06-06 22:04:19 UTC (rev 217859)
+++ trunk/Source/WebCore/platform/URL.cpp	2017-06-06 22:09:44 UTC (rev 217860)
@@ -1273,20 +1273,10 @@
         6669, // Alternate IRC [Apple addition]
         invalidPortNumber, // Used to block all invalid port numbers
     };
-    const unsigned short* const blockedPortListEnd = blockedPortList + WTF_ARRAY_LENGTH(blockedPortList);
 
-#ifndef NDEBUG
-    // The port list must be sorted for binary_search to work.
-    static bool checkedPortList = false;
-    if (!checkedPortList) {
-        for (const unsigned short* p = blockedPortList; p != blockedPortListEnd - 1; ++p)
-            ASSERT(*p < *(p + 1));
-        checkedPortList = true;
-    }
-#endif
-
     // If the port is not in the blocked port list, allow it.
-    if (!std::binary_search(blockedPortList, blockedPortListEnd, port.value()))
+    ASSERT(std::is_sorted(std::begin(blockedPortList), std::end(blockedPortList)));
+    if (!std::binary_search(std::begin(blockedPortList), std::end(blockedPortList), port.value()))
         return true;
 
     // Allow ports 21 and 22 for FTP URLs, as Mozilla does.

Modified: trunk/Source/WebCore/platform/URLParser.cpp (217859 => 217860)


--- trunk/Source/WebCore/platform/URLParser.cpp	2017-06-06 22:04:19 UTC (rev 217859)
+++ trunk/Source/WebCore/platform/URLParser.cpp	2017-06-06 22:09:44 UTC (rev 217860)
@@ -2111,7 +2111,7 @@
 void URLParser::appendNumberToASCIIBuffer(UnsignedIntegerType number)
 {
     LChar buf[sizeof(UnsignedIntegerType) * 3 + 1];
-    LChar* end = buf + WTF_ARRAY_LENGTH(buf);
+    LChar* end = std::end(buf);
     LChar* p = end;
     do {
         *--p = (number % 10) + '0';

Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (217859 => 217860)


--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp	2017-06-06 22:04:19 UTC (rev 217859)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp	2017-06-06 22:09:44 UTC (rev 217860)
@@ -476,7 +476,7 @@
     return m_fonts->glyphDataForCharacter(c, m_fontDescription, variant);
 }
 
-static const char* fontFamiliesWithInvalidCharWidth[] = {
+static const char* const fontFamiliesWithInvalidCharWidth[] = {
     "American Typewriter",
     "Arial Hebrew",
     "Chalkboard",
@@ -524,22 +524,20 @@
     if (family.isEmpty())
         return false;
 
-#if PLATFORM(MAC) || PLATFORM(IOS)
-    // Internal fonts on OS X and iOS also have an invalid entry in the table for avgCharWidth.
+#if PLATFORM(COCOA)
+    // Internal fonts on macOS and iOS also have an invalid entry in the table for avgCharWidth.
     if (primaryFontIsSystemFont())
         return false;
 #endif
 
-    static HashSet<AtomicString>* fontFamiliesWithInvalidCharWidthMap = 0;
+    static NeverDestroyed<const HashSet<AtomicString>> fontFamiliesWithInvalidCharWidthMap = [] {
+        HashSet<AtomicString> map;
+        for (auto* family : fontFamiliesWithInvalidCharWidth)
+            map.add(family);
+        return map;
+    }();
 
-    if (!fontFamiliesWithInvalidCharWidthMap) {
-        fontFamiliesWithInvalidCharWidthMap = new HashSet<AtomicString>;
-
-        for (size_t i = 0; i < WTF_ARRAY_LENGTH(fontFamiliesWithInvalidCharWidth); ++i)
-            fontFamiliesWithInvalidCharWidthMap->add(AtomicString(fontFamiliesWithInvalidCharWidth[i]));
-    }
-
-    return !fontFamiliesWithInvalidCharWidthMap->contains(family);
+    return !fontFamiliesWithInvalidCharWidthMap.get().contains(family);
 }
 
 bool FontCascade::fastAverageCharWidthIfAvailable(float& width) const

Modified: trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm (217859 => 217860)


--- trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm	2017-06-06 22:04:19 UTC (rev 217859)
+++ trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm	2017-06-06 22:09:44 UTC (rev 217860)
@@ -305,8 +305,8 @@
         {'imdc', 'pdf ', 'appl', 0, 0},  
     };
 
-    for (size_t i = 0; i < WTF_ARRAY_LENGTH(componentsToDisable); ++i) 
-        wkQTMovieDisableComponent(componentsToDisable[i]);
+    for (auto& component : componentsToDisable)
+        wkQTMovieDisableComponent(component);
 }
 
 void MediaPlayerPrivateQTKit::createQTMovie(NSURL *url, NSDictionary *movieAttributes)

Modified: trunk/Source/WebCore/platform/network/CacheValidation.cpp (217859 => 217860)


--- trunk/Source/WebCore/platform/network/CacheValidation.cpp	2017-06-06 22:04:19 UTC (rev 217859)
+++ trunk/Source/WebCore/platform/network/CacheValidation.cpp	2017-06-06 22:09:44 UTC (rev 217860)
@@ -43,7 +43,7 @@
 // These response headers are not copied from a revalidated response to the
 // cached response headers. For compatibility, this list is based on Chromium's
 // net/http/http_response_headers.cc.
-const char* const headersToIgnoreAfterRevalidation[] = {
+static const char* const headersToIgnoreAfterRevalidation[] = {
     "allow",
     "connection",
     "etag",
@@ -62,7 +62,7 @@
 // Some header prefixes mean "Don't copy this header from a 304 response.".
 // Rather than listing all the relevant headers, we can consolidate them into
 // this list, also grabbed from Chromium's net/http/http_response_headers.cc.
-const char* const headerPrefixesToIgnoreAfterRevalidation[] = {
+static const char* const headerPrefixesToIgnoreAfterRevalidation[] = {
     "content-",
     "x-content-",
     "x-webkit-"
@@ -74,8 +74,10 @@
         if (equalIgnoringASCIICase(header, headerToIgnore))
             return false;
     }
-    for (size_t i = 0; i < WTF_ARRAY_LENGTH(headerPrefixesToIgnoreAfterRevalidation); i++) {
-        if (header.startsWith(headerPrefixesToIgnoreAfterRevalidation[i], false))
+    for (auto& prefixToIgnore : headerPrefixesToIgnoreAfterRevalidation) {
+        // FIXME: Would be more efficient if we added an overload of
+        // startsWithIgnoringASCIICase that takes a const char*.
+        if (header.startsWithIgnoringASCIICase(prefixToIgnore))
             return false;
     }
     return true;

Modified: trunk/Source/WebCore/platform/text/TextEncodingRegistry.cpp (217859 => 217860)


--- trunk/Source/WebCore/platform/text/TextEncodingRegistry.cpp	2017-06-06 22:04:19 UTC (rev 217859)
+++ trunk/Source/WebCore/platform/text/TextEncodingRegistry.cpp	2017-06-06 22:09:44 UTC (rev 217860)
@@ -176,22 +176,19 @@
 
 static void pruneBlacklistedCodecs()
 {
-    for (size_t i = 0; i < WTF_ARRAY_LENGTH(textEncodingNameBlacklist); ++i) {
-        const char* atomicName = textEncodingNameMap->get(textEncodingNameBlacklist[i]);
+    for (auto& nameFromBlacklist : textEncodingNameBlacklist) {
+        auto* atomicName = textEncodingNameMap->get(nameFromBlacklist);
         if (!atomicName)
             continue;
 
         Vector<const char*> names;
-        TextEncodingNameMap::const_iterator it = textEncodingNameMap->begin();
-        TextEncodingNameMap::const_iterator end = textEncodingNameMap->end();
-        for (; it != end; ++it) {
-            if (it->value == atomicName)
-                names.append(it->key);
+        for (auto& entry : *textEncodingNameMap) {
+            if (entry.value == atomicName)
+                names.append(entry.key);
         }
 
-        size_t length = names.size();
-        for (size_t j = 0; j < length; ++j)
-            textEncodingNameMap->remove(names[j]);
+        for (auto* name : names)
+            textEncodingNameMap->remove(name);
 
         textCodecMap->remove(atomicName);
     }

Modified: trunk/Source/WebCore/platform/text/mac/LocaleMac.mm (217859 => 217860)


--- trunk/Source/WebCore/platform/text/mac/LocaleMac.mm	2017-06-06 22:04:19 UTC (rev 217859)
+++ trunk/Source/WebCore/platform/text/mac/LocaleMac.mm	2017-06-06 22:09:44 UTC (rev 217860)
@@ -126,6 +126,7 @@
 #endif
 
 #if ENABLE(DATE_AND_TIME_INPUT_TYPES)
+
 const Vector<String>& LocaleMac::monthLabels()
 {
     if (!m_monthLabels.isEmpty())
@@ -137,8 +138,8 @@
             m_monthLabels.append(String([array objectAtIndex:i]));
         return m_monthLabels;
     }
-    for (unsigned i = 0; i < WTF_ARRAY_LENGTH(WTF::monthFullName); ++i)
-        m_monthLabels.append(WTF::monthFullName[i]);
+    for (auto& name : WTF::monthFullName)
+        m_monthLabels.append(name);
     return m_monthLabels;
 }
 
@@ -231,8 +232,8 @@
             m_shortMonthLabels.append([array objectAtIndex:i]);
         return m_shortMonthLabels;
     }
-    for (unsigned i = 0; i < WTF_ARRAY_LENGTH(WTF::monthName); ++i)
-        m_shortMonthLabels.append(WTF::monthName[i]);
+    for (auto& name : WTF::monthName)
+        m_shortMonthLabels.append(name);
     return m_shortMonthLabels;
 }
 
@@ -276,6 +277,7 @@
     m_timeAMPMLabels.append([formatter.get() PMSymbol]);
     return m_timeAMPMLabels;
 }
+
 #endif
 
 void LocaleMac::initializeLocaleData()

Modified: trunk/Source/WebCore/rendering/RenderCombineText.cpp (217859 => 217860)


--- trunk/Source/WebCore/rendering/RenderCombineText.cpp	2017-06-06 22:04:19 UTC (rev 217859)
+++ trunk/Source/WebCore/rendering/RenderCombineText.cpp	2017-06-06 22:09:44 UTC (rev 217860)
@@ -136,8 +136,8 @@
     else {
         // Need to try compressed glyphs.
         static const FontWidthVariant widthVariants[] = { HalfWidth, ThirdWidth, QuarterWidth };
-        for (size_t i = 0 ; i < WTF_ARRAY_LENGTH(widthVariants) ; ++i) {
-            description.setWidthVariant(widthVariants[i]); // When modifying this, make sure to keep it in sync with FontPlatformData::isForTextCombine()!
+        for (auto widthVariant : widthVariants) {
+            description.setWidthVariant(widthVariant); // When modifying this, make sure to keep it in sync with FontPlatformData::isForTextCombine()!
 
             FontCascade compressedFont(description, style().fontCascade().letterSpacing(), style().fontCascade().wordSpacing());
             compressedFont.update(fontSelector);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to