Merge to XFA: Make sure string constructors are efficient on literals

Besides the merge, there's one place where a wchar vs. wstring
comparison was being made that no longer compiled.

Original Review URL: https://codereview.chromium.org/1117263004

BUG=pdfium:151
R=thestig@chromium.org

Review URL: https://codereview.chromium.org/1116163003
diff --git a/core/include/fxcrt/fx_string.h b/core/include/fxcrt/fx_string.h
index c46a971..023f765 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 @@
 
     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 @@
 
     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 @@
     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)
 {
diff --git a/core/src/fxcrt/fx_basic_wstring.cpp b/core/src/fxcrt/fx_basic_wstring.cpp
index 9b27537..3465b4a 100644
--- a/core/src/fxcrt/fx_basic_wstring.cpp
+++ b/core/src/fxcrt/fx_basic_wstring.cpp
@@ -63,21 +63,6 @@
         FX_Free(m_pData);
     }
 }
-void CFX_WideString::InitStr(FX_LPCWSTR lpsz, FX_STRSIZE nLen)
-{
-    if (nLen < 0) {
-        nLen = lpsz ? (FX_STRSIZE)FXSYS_wcslen(lpsz) : 0;
-    }
-    if (nLen) {
-        m_pData = FX_AllocStringW(nLen);
-        if (!m_pData) {
-            return;
-        }
-        FXSYS_memcpy32(m_pData->m_String, lpsz, nLen * sizeof(FX_WCHAR));
-    } else {
-        m_pData = NULL;
-    }
-}
 CFX_WideString::CFX_WideString(const CFX_WideString& stringSrc)
 {
     if (stringSrc.m_pData == NULL) {
@@ -92,6 +77,19 @@
         *this = stringSrc;
     }
 }
+CFX_WideString::CFX_WideString(FX_LPCWSTR lpsz, FX_STRSIZE nLen) {
+    if (nLen < 0) {
+        nLen = lpsz ? (FX_STRSIZE)FXSYS_wcslen(lpsz) : 0;
+    }
+    if (nLen) {
+        m_pData = FX_AllocStringW(nLen);
+        if (m_pData) {
+            FXSYS_memcpy32(m_pData->m_String, lpsz, nLen * sizeof(FX_WCHAR));
+        }
+    } else {
+        m_pData = NULL;
+    }
+}
 CFX_WideString::CFX_WideString(FX_WCHAR ch)
 {
     m_pData = FX_AllocStringW(1);
diff --git a/xfa/src/fxfa/src/app/xfa_textlayout.cpp b/xfa/src/fxfa/src/app/xfa_textlayout.cpp
index 82a2313..c577042 100644
--- a/xfa/src/fxfa/src/app/xfa_textlayout.cpp
+++ b/xfa/src/fxfa/src/app/xfa_textlayout.cpp
@@ -520,7 +520,7 @@
         if (wsAttr.IsEmpty()) {

             return FALSE;

         }

-        if (wsAttr.GetAt(0) == FX_WSTRC(L"#")) {

+        if (wsAttr.GetAt(0) == L'#') {

             wsAttr.Delete(0);

         }

         CFX_WideString ws;