From a1ea4276f87f945dfe922f7c37c08f2d203e4e59 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 19 Jun 2018 14:37:12 +0000 Subject: fxcrt::{Byte,Wide}String missing move-assign operator This hasn't been a big deal, since no data is copied, but avoids some ref-count churn in the process. Change-Id: I53c059284aa6806793c59a0c19b3e0d7fe4191d6 Reviewed-on: https://pdfium-review.googlesource.com/35350 Commit-Queue: dsinclair Reviewed-by: dsinclair --- core/fxcrt/widestring.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'core/fxcrt/widestring.cpp') diff --git a/core/fxcrt/widestring.cpp b/core/fxcrt/widestring.cpp index 25f253ea11..cde1973d26 100644 --- a/core/fxcrt/widestring.cpp +++ b/core/fxcrt/widestring.cpp @@ -441,9 +441,16 @@ const WideString& WideString::operator=(const WideStringView& stringSrc) { return *this; } -const WideString& WideString::operator=(const WideString& stringSrc) { - if (m_pData != stringSrc.m_pData) - m_pData = stringSrc.m_pData; +const WideString& WideString::operator=(const WideString& that) { + if (m_pData != that.m_pData) + m_pData = that.m_pData; + + return *this; +} + +const WideString& WideString::operator=(WideString&& that) { + if (m_pData != that.m_pData) + m_pData = std::move(that.m_pData); return *this; } @@ -662,6 +669,10 @@ void WideString::Concat(const wchar_t* pSrcData, size_t nSrcLen) { m_pData.Swap(pNewData); } +intptr_t WideString::ReferenceCountForTesting() const { + return m_pData ? m_pData->m_nRefs : 0; +} + ByteString WideString::UTF8Encode() const { return FX_UTF8Encode(AsStringView()); } -- cgit v1.2.3