Commit e6e968d0 authored by rdevlin.cronin's avatar rdevlin.cronin Committed by Commit bot

Fix String16's move constructor

String16 had a pseudo move constructor that took a const String16&&. The
problem with this is that the point of moving objects is the ability to
clobber the underlying data. If we look at this particular case, the
move ctor tried to then std::move the underlying std::basic_string<>;
this results in passing a const std::basic_string<>&& to the
basic_string ctor. This resolves to the const std::basic_string<>&
*copy* ctor. So in the end, we haven't moved anything.

Fix this by taking a mutable rvalue reference that allows the moving to
work as expected.

BUG=None

Review-Url: https://codereview.chromium.org/2616973002
Cr-Commit-Position: refs/heads/master@{#42147}
parent 38602f1f
......@@ -23,7 +23,7 @@ class String16 {
String16() {}
String16(const String16& other)
: m_impl(other.m_impl), hash_code(other.hash_code) {}
String16(const String16&& other)
String16(String16&& other)
: m_impl(std::move(other.m_impl)), hash_code(other.hash_code) {}
String16(const UChar* characters, size_t size) : m_impl(characters, size) {}
String16(const UChar* characters) // NOLINT(runtime/explicit)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment