Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10465)

Unified Diff: core/include/fxcrt/fx_string.h

Issue 1162203007: Add move constructor for FX string types. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: I can't spell Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/include/fxcrt/fx_string.h
diff --git a/core/include/fxcrt/fx_string.h b/core/include/fxcrt/fx_string.h
index efbe80accbe9b22d5da02e6421712fec89cca260..9903dad942bfae54bd617469fc1c1381f2df03a9 100644
--- a/core/include/fxcrt/fx_string.h
+++ b/core/include/fxcrt/fx_string.h
@@ -178,20 +178,22 @@ class CFX_ByteString
public:
typedef FX_CHAR value_type;
- CFX_ByteString()
- {
- m_pData = NULL;
- }
+ CFX_ByteString() : m_pData(nullptr) { }
+ // Copy constructor.
CFX_ByteString(const CFX_ByteString& str);
- CFX_ByteString(char ch);
+ // Move constructor.
+ inline CFX_ByteString(CFX_ByteString&& other) {
+ this->m_pData = other.m_pData;
+ other.m_pData = nullptr;
+ }
+ CFX_ByteString(char ch);
CFX_ByteString(FX_LPCSTR ptr)
: CFX_ByteString(ptr, ptr ? FXSYS_strlen(ptr) : 0) { }
CFX_ByteString(FX_LPCSTR ptr, FX_STRSIZE len);
-
CFX_ByteString(FX_LPCBYTE ptr, FX_STRSIZE len);
CFX_ByteString(FX_BSTR bstrc);
@@ -623,13 +625,17 @@ class CFX_WideString
public:
typedef FX_WCHAR value_type;
- CFX_WideString()
- {
- m_pData = NULL;
- }
+ CFX_WideString() : m_pData(nullptr) { }
+ // Copy constructor.
CFX_WideString(const CFX_WideString& str);
+ // Move constructor.
+ inline CFX_WideString(CFX_WideString&& other) {
+ this->m_pData = other.m_pData;
+ other.m_pData = nullptr;
+ }
+
CFX_WideString(FX_LPCWSTR ptr)
: CFX_WideString(ptr, ptr ? FXSYS_wcslen(ptr) : 0) { }
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698