Changeset 170055 in webkit


Ignore:
Timestamp:
Jun 17, 2014, 9:16:38 AM (11 years ago)
Author:
mitz@apple.com
Message:

String::isolatedCopy doesn’t return an isolated copy when used on an rvalue reference
https://bugs.webkit.org/show_bug.cgi?id=133968

Reviewed by Anders Carlsson.

Source/WTF:
Made the rvalue reference overload of isolatedCopy() non-const, so that std::move(*this) is
an rvalue reference that can be moved, rather than copied, into the returned String.

  • wtf/text/WTFString.cpp:

(WTF::String::isolatedCopy):

  • wtf/text/WTFString.h:

Tools:

  • TestWebKitAPI/Tests/WTF/WTFString.cpp:

(TestWebKitAPI::TEST): Added a test that an isolated copy of an rvalue reference doesn’t
share an impl() with the original.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r169999 r170055  
     12014-06-17  Dan Bernstein  <mitz@apple.com>
     2
     3        String::isolatedCopy doesn’t return an isolated copy when used on an rvalue reference
     4        https://bugs.webkit.org/show_bug.cgi?id=133968
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Made the rvalue reference overload of isolatedCopy() non-const, so that std::move(*this) is
     9        an rvalue reference that can be moved, rather than copied, into the returned String.
     10
     11        * wtf/text/WTFString.cpp:
     12        (WTF::String::isolatedCopy):
     13        * wtf/text/WTFString.h:
     14
    1152014-06-15  Dan Bernstein  <mitz@apple.com>
    216
  • trunk/Source/WTF/wtf/text/WTFString.cpp

    r169358 r170055  
    689689}
    690690
    691 String String::isolatedCopy() const &&
     691String String::isolatedCopy() &&
    692692{
    693693    if (isSafeToSendToAnotherThread()) {
  • trunk/Source/WTF/wtf/text/WTFString.h

    r169731 r170055  
    374374#if COMPILER_SUPPORTS(CXX_REFERENCE_QUALIFIED_FUNCTIONS)
    375375    WTF_EXPORT_STRING_API String isolatedCopy() const &;
    376     WTF_EXPORT_STRING_API String isolatedCopy() const &&;
     376    WTF_EXPORT_STRING_API String isolatedCopy() &&;
    377377#else
    378378    WTF_EXPORT_STRING_API String isolatedCopy() const;
  • trunk/Tools/ChangeLog

    r170054 r170055  
     12014-06-17  Dan Bernstein  <mitz@apple.com>
     2
     3        String::isolatedCopy doesn’t return an isolated copy when used on an rvalue reference
     4        https://bugs.webkit.org/show_bug.cgi?id=133968
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * TestWebKitAPI/Tests/WTF/WTFString.cpp:
     9        (TestWebKitAPI::TEST): Added a test that an isolated copy of an rvalue reference doesn’t
     10        share an impl() with the original.
     11
    1122014-06-17  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
    213
  • trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp

    r152201 r170055  
    154154}
    155155
     156TEST(WTF, StringIsolatedCopy)
     157{
     158    String original = "1234";
     159    auto copy = std::move(original).isolatedCopy();
     160    ASSERT_FALSE(original.impl() == copy.impl());
     161}
    156162
    157163} // namespace TestWebKitAPI
Note: See TracChangeset for help on using the changeset viewer.