Title: [161362] trunk/Source/WTF
Revision
161362
Author
[email protected]
Date
2014-01-06 12:33:03 -0800 (Mon, 06 Jan 2014)

Log Message

Remove using directives for the std namespace from WTF
https://bugs.webkit.org/show_bug.cgi?id=126524

Reviewed by Alexey Proskuryakov.

Remove the using directives for the std namespace throughout the WTF code.
The more explicit std:: nested name specifier should be used instead.

* wtf/MediaTime.cpp:
(WTF::MediaTime::createWithFloat):
(WTF::MediaTime::createWithDouble):
* wtf/text/StringImpl.cpp:
(WTF::StringImpl::create):
(WTF::StringImpl::lower):
(WTF::StringImpl::upper):
(WTF::StringImpl::foldCase):
(WTF::StringImpl::find):
(WTF::StringImpl::findIgnoringCase):
(WTF::reverseFindInner):
(WTF::StringImpl::reverseFind):
(WTF::reverseFindIgnoringCaseInner):
(WTF::StringImpl::reverseFindIgnoringCase):
(WTF::StringImpl::replace):
(WTF::StringImpl::utf8ForCharacters):
(WTF::StringImpl::utf8ForRange):
* wtf/text/WTFString.cpp:
(WTF::String::append):
(WTF::String::appendInternal):
(WTF::String::insert):
(WTF::String::substringSharingImpl):
(WTF::String::fromUTF8):
(WTF::toIntegralType):
* wtf/win/RunLoopWin.cpp:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (161361 => 161362)


--- trunk/Source/WTF/ChangeLog	2014-01-06 20:23:07 UTC (rev 161361)
+++ trunk/Source/WTF/ChangeLog	2014-01-06 20:33:03 UTC (rev 161362)
@@ -1,3 +1,39 @@
+2014-01-06  Zan Dobersek  <[email protected]>
+
+        Remove using directives for the std namespace from WTF
+        https://bugs.webkit.org/show_bug.cgi?id=126524
+
+        Reviewed by Alexey Proskuryakov.
+
+        Remove the using directives for the std namespace throughout the WTF code.
+        The more explicit std:: nested name specifier should be used instead.
+
+        * wtf/MediaTime.cpp:
+        (WTF::MediaTime::createWithFloat):
+        (WTF::MediaTime::createWithDouble):
+        * wtf/text/StringImpl.cpp:
+        (WTF::StringImpl::create):
+        (WTF::StringImpl::lower):
+        (WTF::StringImpl::upper):
+        (WTF::StringImpl::foldCase):
+        (WTF::StringImpl::find):
+        (WTF::StringImpl::findIgnoringCase):
+        (WTF::reverseFindInner):
+        (WTF::StringImpl::reverseFind):
+        (WTF::reverseFindIgnoringCaseInner):
+        (WTF::StringImpl::reverseFindIgnoringCase):
+        (WTF::StringImpl::replace):
+        (WTF::StringImpl::utf8ForCharacters):
+        (WTF::StringImpl::utf8ForRange):
+        * wtf/text/WTFString.cpp:
+        (WTF::String::append):
+        (WTF::String::appendInternal):
+        (WTF::String::insert):
+        (WTF::String::substringSharingImpl):
+        (WTF::String::fromUTF8):
+        (WTF::toIntegralType):
+        * wtf/win/RunLoopWin.cpp:
+
 2014-01-03  Mark Hahnenberg  <[email protected]>
 
         DoublyLinkedLists can't be concatenated

Modified: trunk/Source/WTF/wtf/MediaTime.cpp (161361 => 161362)


--- trunk/Source/WTF/wtf/MediaTime.cpp	2014-01-06 20:23:07 UTC (rev 161361)
+++ trunk/Source/WTF/wtf/MediaTime.cpp	2014-01-06 20:33:03 UTC (rev 161362)
@@ -33,8 +33,6 @@
 #include <wtf/CheckedArithmetic.h>
 #include <wtf/MathExtras.h>
 
-using namespace std;
-
 namespace WTF {
 
 static int32_t greatestCommonDivisor(int32_t a, int32_t b)
@@ -90,12 +88,12 @@
         return invalidTime();
     if (std::isinf(floatTime))
         return std::signbit(floatTime) ? negativeInfiniteTime() : positiveInfiniteTime();
-    if (floatTime > numeric_limits<int64_t>::max())
+    if (floatTime > std::numeric_limits<int64_t>::max())
         return positiveInfiniteTime();
-    if (floatTime < numeric_limits<int64_t>::min())
+    if (floatTime < std::numeric_limits<int64_t>::min())
         return negativeInfiniteTime();
 
-    while (floatTime * timeScale > numeric_limits<int64_t>::max())
+    while (floatTime * timeScale > std::numeric_limits<int64_t>::max())
         timeScale /= 2;
     return MediaTime(static_cast<int64_t>(floatTime * timeScale), timeScale, Valid);
 }
@@ -106,12 +104,12 @@
         return invalidTime();
     if (std::isinf(doubleTime))
         return std::signbit(doubleTime) ? negativeInfiniteTime() : positiveInfiniteTime();
-    if (doubleTime > numeric_limits<int64_t>::max())
+    if (doubleTime > std::numeric_limits<int64_t>::max())
         return positiveInfiniteTime();
-    if (doubleTime < numeric_limits<int64_t>::min())
+    if (doubleTime < std::numeric_limits<int64_t>::min())
         return negativeInfiniteTime();
 
-    while (doubleTime * timeScale > numeric_limits<int64_t>::max())
+    while (doubleTime * timeScale > std::numeric_limits<int64_t>::max())
         timeScale /= 2;
     return MediaTime(static_cast<int64_t>(doubleTime * timeScale), timeScale, Valid);
 }

Modified: trunk/Source/WTF/wtf/text/StringImpl.cpp (161361 => 161362)


--- trunk/Source/WTF/wtf/text/StringImpl.cpp	2014-01-06 20:23:07 UTC (rev 161361)
+++ trunk/Source/WTF/wtf/text/StringImpl.cpp	2014-01-06 20:33:03 UTC (rev 161362)
@@ -40,8 +40,6 @@
 #include <wtf/DataLog.h>
 #endif
 
-using namespace std;
-
 namespace WTF {
 
 using namespace Unicode;
@@ -297,7 +295,7 @@
     if (!string)
         return *empty();
     size_t length = strlen(reinterpret_cast<const char*>(string));
-    if (length > numeric_limits<unsigned>::max())
+    if (length > std::numeric_limits<unsigned>::max())
         CRASH();
     return create(string, length);
 }
@@ -447,7 +445,7 @@
         return newImpl;
     }
 
-    if (m_length > static_cast<unsigned>(numeric_limits<int32_t>::max()))
+    if (m_length > static_cast<unsigned>(std::numeric_limits<int32_t>::max()))
         CRASH();
     int32_t length = m_length;
 
@@ -474,7 +472,7 @@
     // but in empirical testing, few actual calls to upper() are no-ops, so
     // it wouldn't be worth the extra time for pre-scanning.
 
-    if (m_length > static_cast<unsigned>(numeric_limits<int32_t>::max()))
+    if (m_length > static_cast<unsigned>(std::numeric_limits<int32_t>::max()))
         CRASH();
     int32_t length = m_length;
 
@@ -592,7 +590,7 @@
     // this last part into a shared function that takes a locale string, since this is
     // just like the end of that function.
 
-    if (m_length > static_cast<unsigned>(numeric_limits<int32_t>::max()))
+    if (m_length > static_cast<unsigned>(std::numeric_limits<int32_t>::max()))
         CRASH();
     int length = m_length;
 
@@ -622,7 +620,7 @@
     if (!needsTurkishCasingRules(localeIdentifier) || find('i') == notFound)
         return upper();
 
-    if (m_length > static_cast<unsigned>(numeric_limits<int32_t>::max()))
+    if (m_length > static_cast<unsigned>(std::numeric_limits<int32_t>::max()))
         CRASH();
     int length = m_length;
 
@@ -662,7 +660,7 @@
 
 PassRef<StringImpl> StringImpl::foldCase()
 {
-    if (m_length > static_cast<unsigned>(numeric_limits<int32_t>::max()))
+    if (m_length > static_cast<unsigned>(std::numeric_limits<int32_t>::max()))
         CRASH();
     int32_t length = m_length;
 
@@ -981,11 +979,11 @@
     if (!matchString)
         return notFound;
     size_t matchStringLength = strlen(reinterpret_cast<const char*>(matchString));
-    if (matchStringLength > numeric_limits<unsigned>::max())
+    if (matchStringLength > std::numeric_limits<unsigned>::max())
         CRASH();
     unsigned matchLength = matchStringLength;
     if (!matchLength)
-        return min(index, length());
+        return std::min(index, length());
 
     // Optimization 1: fast case for strings of length 1.
     if (matchLength == 1)
@@ -1029,11 +1027,11 @@
     if (!matchString)
         return notFound;
     size_t matchStringLength = strlen(reinterpret_cast<const char*>(matchString));
-    if (matchStringLength > numeric_limits<unsigned>::max())
+    if (matchStringLength > std::numeric_limits<unsigned>::max())
         CRASH();
     unsigned matchLength = matchStringLength;
     if (!matchLength)
-        return min(index, length());
+        return std::min(index, length());
 
     // Check index & matchLength are in range.
     if (index > length())
@@ -1140,7 +1138,7 @@
     }
 
     if (UNLIKELY(!matchLength))
-        return min(index, length());
+        return std::min(index, length());
 
     // Check index & matchLength are in range.
     if (index > length())
@@ -1184,7 +1182,7 @@
         return notFound;
     unsigned matchLength = matchString->length();
     if (!matchLength)
-        return min(index, length());
+        return std::min(index, length());
 
     // Check index & matchLength are in range.
     if (index > length())
@@ -1226,7 +1224,7 @@
     // only call equal if the hashes match.
 
     // delta is the number of additional times to test; delta == 0 means test only once.
-    unsigned delta = min(index, length - matchLength);
+    unsigned delta = std::min(index, length - matchLength);
     
     unsigned searchHash = 0;
     unsigned matchHash = 0;
@@ -1254,7 +1252,7 @@
     unsigned matchLength = matchString->length();
     unsigned ourLength = length();
     if (!matchLength)
-        return min(index, ourLength);
+        return std::min(index, ourLength);
 
     // Optimization 1: fast case for strings of length 1.
     if (matchLength == 1) {
@@ -1283,7 +1281,7 @@
 ALWAYS_INLINE static size_t reverseFindIgnoringCaseInner(const SearchCharacterType* searchCharacters, const MatchCharacterType* matchCharacters, unsigned index, unsigned length, unsigned matchLength)
 {
     // delta is the number of additional times to test; delta == 0 means test only once.
-    unsigned delta = min(index, length - matchLength);
+    unsigned delta = std::min(index, length - matchLength);
 
     // keep looping until we match
     while (!equalIgnoringCase(searchCharacters + delta, matchCharacters, matchLength)) {
@@ -1302,7 +1300,7 @@
     unsigned matchLength = matchString->length();
     unsigned ourLength = length();
     if (!matchLength)
-        return min(index, ourLength);
+        return std::min(index, ourLength);
 
     // Check index & matchLength are in range.
     if (matchLength > ourLength)
@@ -1454,13 +1452,13 @@
 
 PassRef<StringImpl> StringImpl::replace(unsigned position, unsigned lengthToReplace, StringImpl* str)
 {
-    position = min(position, length());
-    lengthToReplace = min(lengthToReplace, length() - position);
+    position = std::min(position, length());
+    lengthToReplace = std::min(lengthToReplace, length() - position);
     unsigned lengthToInsert = str ? str->length() : 0;
     if (!lengthToReplace && !lengthToInsert)
         return *this;
 
-    if ((length() - lengthToReplace) >= (numeric_limits<unsigned>::max() - lengthToInsert))
+    if ((length() - lengthToReplace) >= (std::numeric_limits<unsigned>::max() - lengthToInsert))
         CRASH();
 
     if (is8Bit() && (!str || str->is8Bit())) {
@@ -1525,12 +1523,12 @@
     if (!matchCount)
         return *this;
 
-    if (repStrLength && matchCount > numeric_limits<unsigned>::max() / repStrLength)
+    if (repStrLength && matchCount > std::numeric_limits<unsigned>::max() / repStrLength)
         CRASH();
 
     unsigned replaceSize = matchCount * repStrLength;
     unsigned newSize = m_length - matchCount;
-    if (newSize >= (numeric_limits<unsigned>::max() - replaceSize))
+    if (newSize >= (std::numeric_limits<unsigned>::max() - replaceSize))
         CRASH();
 
     newSize += replaceSize;
@@ -1602,12 +1600,12 @@
     if (!matchCount)
         return *this;
 
-    if (repStrLength && matchCount > numeric_limits<unsigned>::max() / repStrLength)
+    if (repStrLength && matchCount > std::numeric_limits<unsigned>::max() / repStrLength)
         CRASH();
 
     unsigned replaceSize = matchCount * repStrLength;
     unsigned newSize = m_length - matchCount;
-    if (newSize >= (numeric_limits<unsigned>::max() - replaceSize))
+    if (newSize >= (std::numeric_limits<unsigned>::max() - replaceSize))
         CRASH();
 
     newSize += replaceSize;
@@ -1689,10 +1687,10 @@
         return *this;
     
     unsigned newSize = m_length - matchCount * patternLength;
-    if (repStrLength && matchCount > numeric_limits<unsigned>::max() / repStrLength)
+    if (repStrLength && matchCount > std::numeric_limits<unsigned>::max() / repStrLength)
         CRASH();
 
-    if (newSize > (numeric_limits<unsigned>::max() - matchCount * repStrLength))
+    if (newSize > (std::numeric_limits<unsigned>::max() - matchCount * repStrLength))
         CRASH();
 
     newSize += matchCount * repStrLength;
@@ -2082,7 +2080,7 @@
 {
     if (!length)
         return CString("", 0);
-    if (length > numeric_limits<unsigned>::max() / 3)
+    if (length > std::numeric_limits<unsigned>::max() / 3)
         return CString();
     Vector<char, 1024> bufferVector(length * 3);
     char* buffer = bufferVector.data();
@@ -2109,7 +2107,7 @@
     //  * We could allocate a CStringBuffer with an appropriate size to
     //    have a good chance of being able to write the string into the
     //    buffer without reallocing (say, 1.5 x length).
-    if (length > numeric_limits<unsigned>::max() / 3)
+    if (length > std::numeric_limits<unsigned>::max() / 3)
         return CString();
     Vector<char, 1024> bufferVector(length * 3);
 

Modified: trunk/Source/WTF/wtf/text/WTFString.cpp (161361 => 161362)


--- trunk/Source/WTF/wtf/text/WTFString.cpp	2014-01-06 20:23:07 UTC (rev 161361)
+++ trunk/Source/WTF/wtf/text/WTFString.cpp	2014-01-06 20:33:03 UTC (rev 161362)
@@ -37,12 +37,9 @@
 #include <wtf/unicode/UTF8.h>
 #include <wtf/unicode/Unicode.h>
 
-using namespace std;
-
 namespace WTF {
 
 using namespace Unicode;
-using namespace std;
 
 // Construct a string with UTF-16 data.
 String::String(const UChar* characters, unsigned length)
@@ -104,7 +101,7 @@
         if (m_impl) {
             if (m_impl->is8Bit() && str.m_impl->is8Bit()) {
                 LChar* data;
-                if (str.length() > numeric_limits<unsigned>::max() - m_impl->length())
+                if (str.length() > std::numeric_limits<unsigned>::max() - m_impl->length())
                     CRASH();
                 RefPtr<StringImpl> newImpl = StringImpl::createUninitialized(m_impl->length() + str.length(), data);
                 memcpy(data, m_impl->characters8(), m_impl->length() * sizeof(LChar));
@@ -113,7 +110,7 @@
                 return;
             }
             UChar* data;
-            if (str.length() > numeric_limits<unsigned>::max() - m_impl->length())
+            if (str.length() > std::numeric_limits<unsigned>::max() - m_impl->length())
                 CRASH();
             RefPtr<StringImpl> newImpl = StringImpl::createUninitialized(m_impl->length() + str.length(), data);
             memcpy(data, m_impl->characters(), m_impl->length() * sizeof(UChar));
@@ -133,7 +130,7 @@
     // call to fastMalloc every single time.
     if (m_impl) {
         UChar* data;
-        if (m_impl->length() >= numeric_limits<unsigned>::max())
+        if (m_impl->length() >= std::numeric_limits<unsigned>::max())
             CRASH();
         RefPtr<StringImpl> newImpl = StringImpl::createUninitialized(m_impl->length() + 1, data);
         memcpy(data, m_impl->characters(), m_impl->length() * sizeof(UChar));
@@ -187,7 +184,7 @@
     unsigned strLength = m_impl->length();
 
     if (m_impl->is8Bit()) {
-        if (lengthToAppend > numeric_limits<unsigned>::max() - strLength)
+        if (lengthToAppend > std::numeric_limits<unsigned>::max() - strLength)
             CRASH();
         LChar* data;
         RefPtr<StringImpl> newImpl = StringImpl::createUninitialized(strLength + lengthToAppend, data);
@@ -197,7 +194,7 @@
         return;
     }
 
-    if (lengthToAppend > numeric_limits<unsigned>::max() - strLength)
+    if (lengthToAppend > std::numeric_limits<unsigned>::max() - strLength)
         CRASH();
     UChar* data;
     RefPtr<StringImpl> newImpl = StringImpl::createUninitialized(length() + lengthToAppend, data);
@@ -221,7 +218,7 @@
     unsigned strLength = m_impl->length();
     
     ASSERT(charactersToAppend);
-    if (lengthToAppend > numeric_limits<unsigned>::max() - strLength)
+    if (lengthToAppend > std::numeric_limits<unsigned>::max() - strLength)
         CRASH();
     UChar* data;
     RefPtr<StringImpl> newImpl = StringImpl::createUninitialized(strLength + lengthToAppend, data);
@@ -248,7 +245,7 @@
 
     ASSERT(charactersToInsert);
     UChar* data;
-    if (lengthToInsert > numeric_limits<unsigned>::max() - length())
+    if (lengthToInsert > std::numeric_limits<unsigned>::max() - length())
         CRASH();
     RefPtr<StringImpl> newImpl = StringImpl::createUninitialized(length() + lengthToInsert, data);
     memcpy(data, characters(), position * sizeof(UChar));
@@ -316,8 +313,8 @@
     // FIXME: We used to check against a limit of Heap::minExtraCost / sizeof(UChar).
 
     unsigned stringLength = this->length();
-    offset = min(offset, stringLength);
-    length = min(length, stringLength - offset);
+    offset = std::min(offset, stringLength);
+    length = std::min(length, stringLength - offset);
 
     if (!offset && length == stringLength)
         return *this;
@@ -833,7 +830,7 @@
 
 String String::fromUTF8(const LChar* stringStart, size_t length)
 {
-    if (length > numeric_limits<unsigned>::max())
+    if (length > std::numeric_limits<unsigned>::max())
         CRASH();
 
     if (!stringStart)
@@ -898,8 +895,8 @@
 template <typename IntegralType, typename CharType>
 static inline IntegralType toIntegralType(const CharType* data, size_t length, bool* ok, int base)
 {
-    static const IntegralType integralMax = numeric_limits<IntegralType>::max();
-    static const bool isSigned = numeric_limits<IntegralType>::is_signed;
+    static const IntegralType integralMax = std::numeric_limits<IntegralType>::max();
+    static const bool isSigned = std::numeric_limits<IntegralType>::is_signed;
     const IntegralType maxMultiplier = integralMax / base;
 
     IntegralType value = 0;

Modified: trunk/Source/WTF/wtf/win/RunLoopWin.cpp (161361 => 161362)


--- trunk/Source/WTF/wtf/win/RunLoopWin.cpp	2014-01-06 20:23:07 UTC (rev 161361)
+++ trunk/Source/WTF/wtf/win/RunLoopWin.cpp	2014-01-06 20:33:03 UTC (rev 161362)
@@ -29,8 +29,6 @@
 #include <wtf/CurrentTime.h>
 #include <wtf/WindowsExtras.h>
 
-using namespace std;
-
 namespace WTF {
 
 static const UINT PerformWorkMessage = WM_USER + 1;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to