diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-06-19 14:37:12 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-06-19 14:37:12 +0000 |
commit | a1ea4276f87f945dfe922f7c37c08f2d203e4e59 (patch) | |
tree | 125f9e604c64f1bd38f8ff44d8784b062f0245c4 /core/fxcrt/bytestring.cpp | |
parent | ee3e3a4f3cbaa99ae3609f575ff9b2c329c5df2a (diff) | |
download | pdfium-a1ea4276f87f945dfe922f7c37c08f2d203e4e59.tar.xz |
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 <dsinclair@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcrt/bytestring.cpp')
-rw-r--r-- | core/fxcrt/bytestring.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/core/fxcrt/bytestring.cpp b/core/fxcrt/bytestring.cpp index 872de065ba..984acf9c69 100644 --- a/core/fxcrt/bytestring.cpp +++ b/core/fxcrt/bytestring.cpp @@ -11,6 +11,7 @@ #include <algorithm> #include <cctype> #include <string> +#include <utility> #include "core/fxcrt/cfx_utf8decoder.h" #include "core/fxcrt/fx_codepage.h" @@ -244,9 +245,16 @@ const ByteString& ByteString::operator=(const ByteStringView& stringSrc) { return *this; } -const ByteString& ByteString::operator=(const ByteString& stringSrc) { - if (m_pData != stringSrc.m_pData) - m_pData = stringSrc.m_pData; +const ByteString& ByteString::operator=(const ByteString& that) { + if (m_pData != that.m_pData) + m_pData = that.m_pData; + + return *this; +} + +const ByteString& ByteString::operator=(ByteString&& that) { + if (m_pData != that.m_pData) + m_pData = std::move(that.m_pData); return *this; } @@ -493,6 +501,10 @@ void ByteString::Concat(const char* pSrcData, size_t nSrcLen) { m_pData.Swap(pNewData); } +intptr_t ByteString::ReferenceCountForTesting() const { + return m_pData ? m_pData->m_nRefs : 0; +} + ByteString ByteString::Mid(size_t first, size_t count) const { if (!m_pData) return ByteString(); |