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

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

Issue 1116163003: Merge to XFA: Make sure string constructors are efficient on literals (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 7 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 | core/src/fxcrt/fx_basic_wstring.cpp » ('j') | 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 c46a97166b9b7aee6b811df8054bb6611e3222c3..023f7658c3f9c492d077400b28c7626600a27f3e 100644
--- a/core/include/fxcrt/fx_string.h
+++ b/core/include/fxcrt/fx_string.h
@@ -12,15 +12,11 @@
#include "fx_memory.h"
-class CFX_ByteStringC;
+class CFX_BinaryBuf;
class CFX_ByteString;
-class CFX_WideStringC;
class CFX_WideString;
struct CFX_CharMap;
-class CFX_BinaryBuf;
typedef int FX_STRSIZE;
-class CFX_ByteStringL;
-class CFX_WideStringL;
// An immutable string with caller-provided storage which must outlive the
// string itself.
@@ -208,12 +204,14 @@ public:
CFX_ByteString(char ch);
- CFX_ByteString(FX_LPCSTR ptr, FX_STRSIZE len = -1);
+ 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);
-
CFX_ByteString(FX_BSTR bstrc1, FX_BSTR bstrc2);
~CFX_ByteString();
@@ -631,10 +629,10 @@ public:
CFX_WideString(const CFX_WideString& str);
- CFX_WideString(FX_LPCWSTR ptr, FX_STRSIZE len = -1)
- {
- InitStr(ptr, len);
- }
+ CFX_WideString(FX_LPCWSTR ptr)
+ : CFX_WideString(ptr, ptr ? FXSYS_wcslen(ptr) : 0) { }
+
+ CFX_WideString(FX_LPCWSTR ptr, FX_STRSIZE len);
CFX_WideString(FX_WCHAR ch);
@@ -785,16 +783,16 @@ public:
CFX_ByteString UTF16LE_Encode() const;
void ConvertFrom(const CFX_ByteString& str, CFX_CharMap* pCharMap = NULL);
-protected:
- void InitStr(FX_LPCWSTR ptr, int len);
- CFX_StringDataW* m_pData;
+protected:
void CopyBeforeWrite();
void AllocBeforeWrite(FX_STRSIZE nLen);
void ConcatInPlace(FX_STRSIZE nSrcLen, FX_LPCWSTR lpszSrcData);
void ConcatCopy(FX_STRSIZE nSrc1Len, FX_LPCWSTR lpszSrc1Data, FX_STRSIZE nSrc2Len, FX_LPCWSTR lpszSrc2Data);
void AssignCopy(FX_STRSIZE nSrcLen, FX_LPCWSTR lpszSrcData);
void AllocCopy(CFX_WideString& dest, FX_STRSIZE nCopyLen, FX_STRSIZE nCopyIndex) const;
+
+ CFX_StringDataW* m_pData;
};
inline CFX_WideStringC::CFX_WideStringC(const CFX_WideString& src)
{
« no previous file with comments | « no previous file | core/src/fxcrt/fx_basic_wstring.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698