Title: [206196] trunk/Source
Revision
206196
Author
achristen...@apple.com
Date
2016-09-20 20:10:57 -0700 (Tue, 20 Sep 2016)

Log Message

Require WTFMove for String::adopt
https://bugs.webkit.org/show_bug.cgi?id=162313

Reviewed by Yusuke Suzuki.

Source/_javascript_Core:

* runtime/JSStringBuilder.h:
(JSC::JSStringBuilder::build):

Source/WebCore:

No change in behavior.  This just makes it more clear what is going on when a String adopts a Vector.

* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneDeserializer::readString):
* css/parser/CSSParser.cpp:
(WebCore::quoteCSSStringInternal):
* dom/Document.cpp:
(WebCore::canonicalizedTitle):
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::normalizeSpaces):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::ExternalCharacterTokenBuffer::takeRemainingWhitespace):
* platform/Length.cpp:
(WebCore::newCoordsArray):
* platform/URLParser.cpp:
(WebCore::URLParser::parse):
(WebCore::URLParser::serialize):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::ReplicaState::cloneID):
* platform/text/TextCodecUTF16.cpp:
(WebCore::TextCodecUTF16::decode):
* platform/text/TextCodecUTF8.cpp:
(WebCore::TextCodecUTF8::decode):
* platform/text/mac/TextCodecMac.cpp:
(WebCore::TextCodecMac::decode):

Source/WTF:

* wtf/text/StringImpl.cpp:
(WTF::StringImpl::removeCharacters):
(WTF::StringImpl::simplifyMatchedCharactersToSpace):
(WTF::StringImpl::adopt):
* wtf/text/StringImpl.h:
(WTF::StringImpl::adopt):
* wtf/text/WTFString.h:
(WTF::String::adopt):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (206195 => 206196)


--- trunk/Source/_javascript_Core/ChangeLog	2016-09-21 02:46:17 UTC (rev 206195)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-09-21 03:10:57 UTC (rev 206196)
@@ -1,3 +1,13 @@
+2016-09-20  Alex Christensen  <achristen...@webkit.org>
+
+        Require WTFMove for String::adopt
+        https://bugs.webkit.org/show_bug.cgi?id=162313
+
+        Reviewed by Yusuke Suzuki.
+
+        * runtime/JSStringBuilder.h:
+        (JSC::JSStringBuilder::build):
+
 2016-09-20  Joseph Pecoraro  <pecor...@apple.com>
 
         REGRESSION(r205692): Minified builds have broken inspector

Modified: trunk/Source/_javascript_Core/runtime/JSStringBuilder.h (206195 => 206196)


--- trunk/Source/_javascript_Core/runtime/JSStringBuilder.h	2016-09-21 02:46:17 UTC (rev 206195)
+++ trunk/Source/_javascript_Core/runtime/JSStringBuilder.h	2016-09-21 03:10:57 UTC (rev 206196)
@@ -79,12 +79,12 @@
             buffer8.shrinkToFit();
             if (!buffer8.data())
                 return throwOutOfMemoryError(exec, scope);
-            return jsString(exec, String::adopt(buffer8));
+            return jsString(exec, String::adopt(WTFMove(buffer8)));
         }
         buffer16.shrinkToFit();
         if (!buffer16.data())
             return throwOutOfMemoryError(exec, scope);
-        return jsString(exec, String::adopt(buffer16));
+        return jsString(exec, String::adopt(WTFMove(buffer16)));
     }
 
 private:

Modified: trunk/Source/WTF/ChangeLog (206195 => 206196)


--- trunk/Source/WTF/ChangeLog	2016-09-21 02:46:17 UTC (rev 206195)
+++ trunk/Source/WTF/ChangeLog	2016-09-21 03:10:57 UTC (rev 206196)
@@ -1,3 +1,19 @@
+2016-09-20  Alex Christensen  <achristen...@webkit.org>
+
+        Require WTFMove for String::adopt
+        https://bugs.webkit.org/show_bug.cgi?id=162313
+
+        Reviewed by Yusuke Suzuki.
+
+        * wtf/text/StringImpl.cpp:
+        (WTF::StringImpl::removeCharacters):
+        (WTF::StringImpl::simplifyMatchedCharactersToSpace):
+        (WTF::StringImpl::adopt):
+        * wtf/text/StringImpl.h:
+        (WTF::StringImpl::adopt):
+        * wtf/text/WTFString.h:
+        (WTF::String::adopt):
+
 2016-09-20  Filip Pizlo  <fpi...@apple.com>
 
         Make MarkedBlock state tracking support overlapped allocation and marking state

Modified: trunk/Source/WTF/wtf/text/StringImpl.cpp (206195 => 206196)


--- trunk/Source/WTF/wtf/text/StringImpl.cpp	2016-09-21 02:46:17 UTC (rev 206195)
+++ trunk/Source/WTF/wtf/text/StringImpl.cpp	2016-09-21 03:10:57 UTC (rev 206196)
@@ -831,7 +831,7 @@
 
     data.shrink(outc);
 
-    return adopt(data);
+    return adopt(WTFMove(data));
 }
 
 Ref<StringImpl> StringImpl::removeCharacters(CharacterMatchFunctionPtr findMatch)
@@ -875,7 +875,7 @@
     
     data.shrink(outc);
     
-    return adopt(data);
+    return adopt(WTFMove(data));
 }
 
 Ref<StringImpl> StringImpl::simplifyWhiteSpace()
@@ -2002,7 +2002,7 @@
     return U_LEFT_TO_RIGHT;
 }
 
-Ref<StringImpl> StringImpl::adopt(StringBuffer<LChar>& buffer)
+Ref<StringImpl> StringImpl::adopt(StringBuffer<LChar>&& buffer)
 {
     unsigned length = buffer.length();
     if (!length)
@@ -2010,7 +2010,7 @@
     return adoptRef(*new StringImpl(buffer.release(), length));
 }
 
-Ref<StringImpl> StringImpl::adopt(StringBuffer<UChar>& buffer)
+Ref<StringImpl> StringImpl::adopt(StringBuffer<UChar>&& buffer)
 {
     unsigned length = buffer.length();
     if (!length)

Modified: trunk/Source/WTF/wtf/text/StringImpl.h (206195 => 206196)


--- trunk/Source/WTF/wtf/text/StringImpl.h	2016-09-21 02:46:17 UTC (rev 206195)
+++ trunk/Source/WTF/wtf/text/StringImpl.h	2016-09-21 03:10:57 UTC (rev 206196)
@@ -426,7 +426,7 @@
     static unsigned dataOffset() { return OBJECT_OFFSETOF(StringImpl, m_data8); }
 
     template<typename CharType, size_t inlineCapacity, typename OverflowHandler>
-    static Ref<StringImpl> adopt(Vector<CharType, inlineCapacity, OverflowHandler>& vector)
+    static Ref<StringImpl> adopt(Vector<CharType, inlineCapacity, OverflowHandler>&& vector)
     {
         if (size_t size = vector.size()) {
             ASSERT(vector.data());
@@ -437,8 +437,8 @@
         return *empty();
     }
 
-    WTF_EXPORT_STRING_API static Ref<StringImpl> adopt(StringBuffer<UChar>&);
-    WTF_EXPORT_STRING_API static Ref<StringImpl> adopt(StringBuffer<LChar>&);
+    WTF_EXPORT_STRING_API static Ref<StringImpl> adopt(StringBuffer<UChar>&&);
+    WTF_EXPORT_STRING_API static Ref<StringImpl> adopt(StringBuffer<LChar>&&);
 
     unsigned length() const { return m_length; }
     static ptrdiff_t lengthMemoryOffset() { return OBJECT_OFFSETOF(StringImpl, m_length); }

Modified: trunk/Source/WTF/wtf/text/WTFString.h (206195 => 206196)


--- trunk/Source/WTF/wtf/text/WTFString.h	2016-09-21 02:46:17 UTC (rev 206195)
+++ trunk/Source/WTF/wtf/text/WTFString.h	2016-09-21 03:10:57 UTC (rev 206196)
@@ -138,10 +138,10 @@
 
     void swap(String& o) { m_impl.swap(o.m_impl); }
 
-    static String adopt(StringBuffer<LChar>& buffer) { return StringImpl::adopt(buffer); }
-    static String adopt(StringBuffer<UChar>& buffer) { return StringImpl::adopt(buffer); }
+    static String adopt(StringBuffer<LChar>&& buffer) { return StringImpl::adopt(WTFMove(buffer)); }
+    static String adopt(StringBuffer<UChar>&& buffer) { return StringImpl::adopt(WTFMove(buffer)); }
     template<typename CharacterType, size_t inlineCapacity, typename OverflowHandler>
-    static String adopt(Vector<CharacterType, inlineCapacity, OverflowHandler>& vector) { return StringImpl::adopt(vector); }
+    static String adopt(Vector<CharacterType, inlineCapacity, OverflowHandler>&& vector) { return StringImpl::adopt(WTFMove(vector)); }
 
     bool isNull() const { return !m_impl; }
     bool isEmpty() const { return !m_impl || !m_impl->length(); }

Modified: trunk/Source/WebCore/ChangeLog (206195 => 206196)


--- trunk/Source/WebCore/ChangeLog	2016-09-21 02:46:17 UTC (rev 206195)
+++ trunk/Source/WebCore/ChangeLog	2016-09-21 03:10:57 UTC (rev 206196)
@@ -1,3 +1,36 @@
+2016-09-20  Alex Christensen  <achristen...@webkit.org>
+
+        Require WTFMove for String::adopt
+        https://bugs.webkit.org/show_bug.cgi?id=162313
+
+        Reviewed by Yusuke Suzuki.
+
+        No change in behavior.  This just makes it more clear what is going on when a String adopts a Vector.
+
+        * bindings/js/SerializedScriptValue.cpp:
+        (WebCore::CloneDeserializer::readString):
+        * css/parser/CSSParser.cpp:
+        (WebCore::quoteCSSStringInternal):
+        * dom/Document.cpp:
+        (WebCore::canonicalizedTitle):
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::normalizeSpaces):
+        * html/parser/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::ExternalCharacterTokenBuffer::takeRemainingWhitespace):
+        * platform/Length.cpp:
+        (WebCore::newCoordsArray):
+        * platform/URLParser.cpp:
+        (WebCore::URLParser::parse):
+        (WebCore::URLParser::serialize):
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::ReplicaState::cloneID):
+        * platform/text/TextCodecUTF16.cpp:
+        (WebCore::TextCodecUTF16::decode):
+        * platform/text/TextCodecUTF8.cpp:
+        (WebCore::TextCodecUTF8::decode):
+        * platform/text/mac/TextCodecMac.cpp:
+        (WebCore::TextCodecMac::decode):
+
 2016-09-20  Jer Noble  <jer.no...@apple.com>
 
         Adopt MRMediaRemoteSetParentApplication.

Modified: trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp (206195 => 206196)


--- trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp	2016-09-21 02:46:17 UTC (rev 206195)
+++ trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp	2016-09-21 03:10:57 UTC (rev 206196)
@@ -1707,7 +1707,7 @@
             readLittleEndian(ptr, end, ch);
             buffer.append(ch);
         }
-        str = String::adopt(buffer);
+        str = String::adopt(WTFMove(buffer));
 #endif
         return true;
     }

Modified: trunk/Source/WebCore/css/parser/CSSParser.cpp (206195 => 206196)


--- trunk/Source/WebCore/css/parser/CSSParser.cpp	2016-09-21 02:46:17 UTC (rev 206195)
+++ trunk/Source/WebCore/css/parser/CSSParser.cpp	2016-09-21 03:10:57 UTC (rev 206196)
@@ -13644,7 +13644,7 @@
     buffer[index++] = '\'';
 
     ASSERT(quotedStringSize == index);
-    return String::adopt(buffer);
+    return String::adopt(WTFMove(buffer));
 }
 
 // We use single quotes for now because markup.cpp uses double quotes.

Modified: trunk/Source/WebCore/dom/Document.cpp (206195 => 206196)


--- trunk/Source/WebCore/dom/Document.cpp	2016-09-21 02:46:17 UTC (rev 206195)
+++ trunk/Source/WebCore/dom/Document.cpp	2016-09-21 03:10:57 UTC (rev 206196)
@@ -1574,7 +1574,7 @@
     // Replace the backslashes with currency symbols if the encoding requires it.
     document->displayBufferModifiedByEncoding(buffer.characters(), buffer.length());
     
-    return StringWithDirection(String::adopt(buffer), titleWithDirection.direction());
+    return StringWithDirection(String::adopt(WTFMove(buffer)), titleWithDirection.direction());
 }
 
 void Document::updateTitle(const StringWithDirection& title)

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (206195 => 206196)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2016-09-21 02:46:17 UTC (rev 206195)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2016-09-21 03:10:57 UTC (rev 206196)
@@ -2357,7 +2357,7 @@
         if (isSpaceThatNeedsReplacing(charVector[i]))
             charVector[i] = ' ';
     }
-    text = String::adopt(charVector);
+    text = String::adopt(WTFMove(charVector));
 }
 
 Ref<TextMetrics> CanvasRenderingContext2D::measureText(const String& text)

Modified: trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp (206195 => 206196)


--- trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp	2016-09-21 02:46:17 UTC (rev 206195)
+++ trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp	2016-09-21 03:10:57 UTC (rev 206196)
@@ -219,7 +219,7 @@
         if (whitespace.isEmpty())
             return String();
 
-        return String::adopt(whitespace);
+        return String::adopt(WTFMove(whitespace));
     }
 
 private:

Modified: trunk/Source/WebCore/platform/Length.cpp (206195 => 206196)


--- trunk/Source/WebCore/platform/Length.cpp	2016-09-21 02:46:17 UTC (rev 206195)
+++ trunk/Source/WebCore/platform/Length.cpp	2016-09-21 03:10:57 UTC (rev 206196)
@@ -99,7 +99,7 @@
         else
             spacified[i] = cc;
     }
-    RefPtr<StringImpl> str = StringImpl::adopt(spacified);
+    RefPtr<StringImpl> str = StringImpl::adopt(WTFMove(spacified));
 
     str = str->simplifyWhiteSpace();
 

Modified: trunk/Source/WebCore/platform/URLParser.cpp (206195 => 206196)


--- trunk/Source/WebCore/platform/URLParser.cpp	2016-09-21 02:46:17 UTC (rev 206195)
+++ trunk/Source/WebCore/platform/URLParser.cpp	2016-09-21 03:10:57 UTC (rev 206196)
@@ -1599,10 +1599,10 @@
         break;
     }
 
-    if (m_unicodeFragmentBuffer.isEmpty()) {
-        // FIXME: String::adopt should require a WTFMove.
-        m_url.m_string = String::adopt(m_asciiBuffer);
-    } else {
+    if (m_unicodeFragmentBuffer.isEmpty())
+        m_url.m_string = String::adopt(WTFMove(m_asciiBuffer));
+    else {
+        // FIXME: This should use a Vector<UChar> and adopt it.
         StringBuilder builder;
         builder.reserveCapacity(m_asciiBuffer.size() + m_unicodeFragmentBuffer.size());
         builder.append(m_asciiBuffer.data(), m_asciiBuffer.size());
@@ -2212,7 +2212,7 @@
         output.append('=');
         serializeURLEncodedForm(tuple.second, output);
     }
-    return String::adopt(output);
+    return String::adopt(WTFMove(output));
 }
 
 bool URLParser::allValuesEqual(const URL& a, const URL& b)

Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (206195 => 206196)


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2016-09-21 02:46:17 UTC (rev 206195)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2016-09-21 03:10:57 UTC (rev 206196)
@@ -2570,7 +2570,7 @@
         currChar = (currChar << 1) | m_replicaBranches[i];
     }
     
-    return String::adopt(result);
+    return String::adopt(WTFMove(result));
 }
 
 PassRefPtr<PlatformCALayer> GraphicsLayerCA::replicatedLayerRoot(ReplicaState& replicaState)

Modified: trunk/Source/WebCore/platform/text/LocaleICU.cpp (206195 => 206196)


--- trunk/Source/WebCore/platform/text/LocaleICU.cpp	2016-09-21 02:46:17 UTC (rev 206195)
+++ trunk/Source/WebCore/platform/text/LocaleICU.cpp	2016-09-21 03:10:57 UTC (rev 206196)
@@ -78,7 +78,7 @@
     unum_getSymbol(m_numberFormat, symbol, buffer.data(), bufferLength, &status);
     if (U_FAILURE(status))
         return String();
-    return String::adopt(buffer);
+    return String::adopt(WTFMove(buffer));
 }
 
 String LocaleICU::decimalTextAttribute(UNumberFormatTextAttribute tag)
@@ -94,7 +94,7 @@
     ASSERT(U_SUCCESS(status));
     if (U_FAILURE(status))
         return String();
-    return String::adopt(buffer);
+    return String::adopt(WTFMove(buffer));
 }
 #endif
 
@@ -158,7 +158,7 @@
     udat_toPattern(dateFormat, TRUE, buffer.data(), length, &status);
     if (U_FAILURE(status))
         return emptyString();
-    return String::adopt(buffer);
+    return String::adopt(WTFMove(buffer));
 }
 
 std::unique_ptr<Vector<String>> LocaleICU::createLabelVector(const UDateFormat* dateFormat, UDateFormatSymbolType type, int32_t startIndex, int32_t size)
@@ -180,7 +180,7 @@
         udat_getSymbols(dateFormat, type, startIndex + i, buffer.data(), length, &status);
         if (U_FAILURE(status))
             return std::make_unique<Vector<String>>();
-        labels->append(String::adopt(buffer));
+        labels->append(String::adopt(WTFMove(buffer)));
     }
     return WTFMove(labels);
 }
@@ -270,7 +270,7 @@
         status = U_ZERO_ERROR;
         udatpg_getBestPattern(patternGenerator, skeleton, skeletonLength, buffer.data(), length, &status);
         if (U_SUCCESS(status))
-            format = String::adopt(buffer);
+            format = String::adopt(WTFMove(buffer));
     }
     udatpg_close(patternGenerator);
     return format;

Modified: trunk/Source/WebCore/platform/text/TextCodecUTF16.cpp (206195 => 206196)


--- trunk/Source/WebCore/platform/text/TextCodecUTF16.cpp	2016-09-21 02:46:17 UTC (rev 206195)
+++ trunk/Source/WebCore/platform/text/TextCodecUTF16.cpp	2016-09-21 03:10:57 UTC (rev 206196)
@@ -111,7 +111,7 @@
 
     buffer.shrink(q - buffer.characters());
 
-    return String::adopt(buffer);
+    return String::adopt(WTFMove(buffer));
 }
 
 CString TextCodecUTF16::encode(const UChar* characters, size_t length, UnencodableHandling)

Modified: trunk/Source/WebCore/platform/text/TextCodecUTF8.cpp (206195 => 206196)


--- trunk/Source/WebCore/platform/text/TextCodecUTF8.cpp	2016-09-21 02:46:17 UTC (rev 206195)
+++ trunk/Source/WebCore/platform/text/TextCodecUTF8.cpp	2016-09-21 03:10:57 UTC (rev 206196)
@@ -343,7 +343,7 @@
 
     buffer.shrink(destination - buffer.characters());
 
-    return String::adopt(buffer);
+    return String::adopt(WTFMove(buffer));
 
 upConvertTo16Bit:
     StringBuffer<UChar> buffer16(m_partialSequenceSize + length);
@@ -419,7 +419,7 @@
     
     buffer16.shrink(destination16 - buffer16.characters());
     
-    return String::adopt(buffer16);
+    return String::adopt(WTFMove(buffer16));
 }
 
 CString TextCodecUTF8::encode(const UChar* characters, size_t length, UnencodableHandling)

Modified: trunk/Source/WebCore/platform/text/mac/TextCodecMac.cpp (206195 => 206196)


--- trunk/Source/WebCore/platform/text/mac/TextCodecMac.cpp	2016-09-21 02:46:17 UTC (rev 206195)
+++ trunk/Source/WebCore/platform/text/mac/TextCodecMac.cpp	2016-09-21 03:10:57 UTC (rev 206196)
@@ -264,7 +264,7 @@
         result.append(buffer, bytesWritten / sizeof(UChar));
     }
 
-    String resultString = String::adopt(result);
+    String resultString = String::adopt(WTFMove(result));
 
     // <rdar://problem/3225472>
     // Simplified Chinese pages use the code A3A0 to mean "full-width space".

Modified: trunk/Source/WebCore/platform/win/FileSystemWin.cpp (206195 => 206196)


--- trunk/Source/WebCore/platform/win/FileSystemWin.cpp	2016-09-21 02:46:17 UTC (rev 206195)
+++ trunk/Source/WebCore/platform/win/FileSystemWin.cpp	2016-09-21 03:10:57 UTC (rev 206196)
@@ -190,7 +190,7 @@
 
     buffer.shrink(wcslen(buffer.data()));
 
-    return String::adopt(buffer);
+    return String::adopt(WTFMove(buffer));
 }
 
 #if !USE(CF)
@@ -272,7 +272,7 @@
     if (FAILED(SHGetFolderPathW(0, pathIdentifier | CSIDL_FLAG_CREATE, 0, 0, buffer.data())))
         return String();
     buffer.resize(wcslen(buffer.data()));
-    String directory = String::adopt(buffer);
+    String directory = String::adopt(WTFMove(buffer));
 
     DEPRECATED_DEFINE_STATIC_LOCAL(String, companyNameDirectory, (ASCIILiteral("Apple Computer\\")));
     directory = pathByAppendingComponent(directory, companyNameDirectory + bundleName());
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to