Move fxcrt::{Byte,Wide}Strings with std::move().

Remove some string copies in barcode that were noticed whilst
looking for moves.

Change-Id: Ieda34d00f633576ba1f0dca283dcdabfb36f236c
Reviewed-on: https://pdfium-review.googlesource.com/35410
Reviewed-by: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/font/cpdf_tounicodemap.cpp b/core/fpdfapi/font/cpdf_tounicodemap.cpp
index 7b5936c..e891731 100644
--- a/core/fpdfapi/font/cpdf_tounicodemap.cpp
+++ b/core/fpdfapi/font/cpdf_tounicodemap.cpp
@@ -6,6 +6,8 @@
 
 #include "core/fpdfapi/font/cpdf_tounicodemap.h"
 
+#include <utility>
+
 #include "core/fpdfapi/cpdf_modulemgr.h"
 #include "core/fpdfapi/font/cpdf_cid2unicodemap.h"
 #include "core/fpdfapi/page/cpdf_pagemodule.h"
@@ -205,7 +207,7 @@
               m_Map[code] = GetUnicode();
               m_MultiCharBuf.AppendChar(retcode.GetLength());
               m_MultiCharBuf << retcode;
-              destcode = retcode;
+              destcode = std::move(retcode);
             }
           }
         }
diff --git a/core/fpdfapi/page/cpdf_contentmark.cpp b/core/fpdfapi/page/cpdf_contentmark.cpp
index e17a305..deddf3c 100644
--- a/core/fpdfapi/page/cpdf_contentmark.cpp
+++ b/core/fpdfapi/page/cpdf_contentmark.cpp
@@ -31,10 +31,10 @@
   return pData ? pData->GetMarkedContentID() : -1;
 }
 
-void CPDF_ContentMark::AddMark(const ByteString& name,
+void CPDF_ContentMark::AddMark(ByteString name,
                                const CPDF_Dictionary* pDict,
                                bool bDirect) {
-  m_Ref.GetPrivateCopy()->AddMark(name, pDict, bDirect);
+  m_Ref.GetPrivateCopy()->AddMark(std::move(name), pDict, bDirect);
 }
 
 void CPDF_ContentMark::DeleteLastMark() {
@@ -68,11 +68,11 @@
   return -1;
 }
 
-void CPDF_ContentMark::MarkData::AddMark(const ByteString& name,
+void CPDF_ContentMark::MarkData::AddMark(ByteString name,
                                          const CPDF_Dictionary* pDict,
                                          bool bDirect) {
   CPDF_ContentMarkItem item;
-  item.SetName(name);
+  item.SetName(std::move(name));
   if (pDict) {
     if (bDirect)
       item.SetDirectDict(ToDictionary(pDict->Clone()));
diff --git a/core/fpdfapi/page/cpdf_contentmark.h b/core/fpdfapi/page/cpdf_contentmark.h
index 1d8b9e2..494c206 100644
--- a/core/fpdfapi/page/cpdf_contentmark.h
+++ b/core/fpdfapi/page/cpdf_contentmark.h
@@ -25,9 +25,7 @@
   size_t CountItems() const;
   const CPDF_ContentMarkItem& GetItem(size_t i) const;
 
-  void AddMark(const ByteString& name,
-               const CPDF_Dictionary* pDict,
-               bool bDirect);
+  void AddMark(ByteString name, const CPDF_Dictionary* pDict, bool bDirect);
   void DeleteLastMark();
 
   bool HasRef() const { return !!m_Ref; }
@@ -43,7 +41,7 @@
     const CPDF_ContentMarkItem& GetItem(size_t index) const;
 
     int GetMarkedContentID() const;
-    void AddMark(const ByteString& name,
+    void AddMark(ByteString name,
                  const CPDF_Dictionary* pDict,
                  bool bDictNeedClone);
     void DeleteLastMark();
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 0cc81f1..2fbb73b 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -184,7 +184,7 @@
         if (!fullname.IsEmpty()) {
           AbbrReplacementOp op;
           op.is_replace_key = true;
-          op.key = key;
+          op.key = std::move(key);
           op.replacement = fullname;
           replacements.push_back(op);
           key = fullname;
@@ -606,9 +606,8 @@
       return;
     bDirect = false;
   }
-  if (const CPDF_Dictionary* pDict = pProperty->AsDictionary()) {
-    m_CurContentMark.AddMark(tag, pDict, bDirect);
-  }
+  if (const CPDF_Dictionary* pDict = pProperty->AsDictionary())
+    m_CurContentMark.AddMark(std::move(tag), pDict, bDirect);
 }
 
 void CPDF_StreamContentParser::Handle_BeginImage() {
@@ -755,20 +754,23 @@
   if (pXObject->GetDict())
     type = pXObject->GetDict()->GetStringFor("Subtype");
 
+  if (type == "Form") {
+    AddForm(pXObject);
+    return;
+  }
+
   if (type == "Image") {
     CPDF_ImageObject* pObj = pXObject->IsInline()
                                  ? AddImage(std::unique_ptr<CPDF_Stream>(
                                        ToStream(pXObject->Clone())))
                                  : AddImage(pXObject->GetObjNum());
 
-    m_LastImageName = name;
+    m_LastImageName = std::move(name);
     if (pObj) {
       m_pLastImage = pObj->GetImage();
       if (m_pLastImage->IsMask())
         m_pObjectHolder->AddImageMaskBoundingBox(pObj->GetRect());
     }
-  } else if (type == "Form") {
-    AddForm(pXObject);
   }
 }
 
@@ -1307,7 +1309,7 @@
       ByteString str = pObj->GetString();
       if (str.IsEmpty())
         continue;
-      strs[iSegment] = str;
+      strs[iSegment] = std::move(str);
       kernings[iSegment++] = 0;
     } else {
       float num = pObj->GetNumber();
diff --git a/core/fpdfapi/parser/fpdf_parser_decode.cpp b/core/fpdfapi/parser/fpdf_parser_decode.cpp
index aafb812..0ca9b4e 100644
--- a/core/fpdfapi/parser/fpdf_parser_decode.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp
@@ -404,7 +404,7 @@
         decoder = "DCTDecode";
       else if (decoder == "CCF")
         decoder = "CCITTFaxDecode";
-      *ImageEncoding = decoder;
+      *ImageEncoding = std::move(decoder);
       *pImageParms = pParam;
       *dest_buf = last_buf;
       *dest_size = last_size;
diff --git a/core/fpdfdoc/cpdf_formcontrol.cpp b/core/fpdfdoc/cpdf_formcontrol.cpp
index 2100d4e..a80b029 100644
--- a/core/fpdfdoc/cpdf_formcontrol.cpp
+++ b/core/fpdfdoc/cpdf_formcontrol.cpp
@@ -149,11 +149,10 @@
 void CPDF_FormControl::CheckControl(bool bChecked) {
   ASSERT(GetType() == CPDF_FormField::CheckBox ||
          GetType() == CPDF_FormField::RadioButton);
-  ByteString csOn = GetOnStateName();
   ByteString csOldAS = m_pWidgetDict->GetStringFor("AS", "Off");
   ByteString csAS = "Off";
   if (bChecked)
-    csAS = csOn;
+    csAS = GetOnStateName();
   if (csOldAS == csAS)
     return;
   m_pWidgetDict->SetNewFor<CPDF_Name>("AS", csAS);
diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp
index 8dcc9e6..2f05ad8 100644
--- a/core/fpdfdoc/cpdf_formfield.cpp
+++ b/core/fpdfdoc/cpdf_formfield.cpp
@@ -92,7 +92,7 @@
     WideString short_name = pLevel->GetUnicodeTextFor("T");
     if (!short_name.IsEmpty()) {
       if (full_name.IsEmpty())
-        full_name = short_name;
+        full_name = std::move(short_name);
       else
         full_name = short_name + L"." + full_name;
     }
diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp
index de37709..b18310c 100644
--- a/core/fpdfdoc/cpdf_interform.cpp
+++ b/core/fpdfdoc/cpdf_interform.cpp
@@ -206,8 +206,7 @@
     if (!pFont)
       continue;
 
-    ByteString csBaseFont;
-    csBaseFont = pFont->GetBaseFont();
+    ByteString csBaseFont = pFont->GetBaseFont();
     csBaseFont.Remove(' ');
     if (csBaseFont == csFontName) {
       *csNameTag = csKey;
@@ -228,7 +227,7 @@
 
   ByteString csTag;
   if (FindFont(pFormDict, pFont, &csTag)) {
-    *csNameTag = csTag;
+    *csNameTag = std::move(csTag);
     return;
   }
   if (!pFormDict)
@@ -261,7 +260,7 @@
   ByteString csTemp;
   CPDF_Font* pFont = GetNativeFont(pFormDict, pDocument, charSet, &csTemp);
   if (pFont) {
-    *csNameTag = csTemp;
+    *csNameTag = std::move(csTemp);
     return pFont;
   }
   ByteString csFontName = CPDF_InterForm::GetNativeFont(charSet, nullptr);
diff --git a/core/fpdfdoc/cpdf_structelement.cpp b/core/fpdfdoc/cpdf_structelement.cpp
index 24c028f..d8fc0d8 100644
--- a/core/fpdfdoc/cpdf_structelement.cpp
+++ b/core/fpdfdoc/cpdf_structelement.cpp
@@ -6,6 +6,8 @@
 
 #include "core/fpdfdoc/cpdf_structelement.h"
 
+#include <utility>
+
 #include "core/fpdfapi/parser/cpdf_array.h"
 #include "core/fpdfapi/parser/cpdf_dictionary.h"
 #include "core/fpdfapi/parser/cpdf_name.h"
@@ -36,7 +38,7 @@
   if (pTree->GetRoleMap()) {
     ByteString mapped = pTree->GetRoleMap()->GetStringFor(m_Type);
     if (!mapped.IsEmpty())
-      m_Type = mapped;
+      m_Type = std::move(mapped);
   }
   LoadKids(pDict);
 }
diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp
index 1e24746..379a8b9 100644
--- a/fpdfsdk/cpdfsdk_interform.cpp
+++ b/fpdfsdk/cpdfsdk_interform.cpp
@@ -10,6 +10,7 @@
 #include <memory>
 #include <sstream>
 #include <string>
+#include <utility>
 #include <vector>
 
 #include "core/fpdfapi/page/cpdf_page.h"
@@ -322,13 +323,11 @@
       WideString script = action.GetJavaScript();
       if (!script.IsEmpty()) {
         WideString Value = sValue;
-
         IJS_Runtime::ScopedEventContext pContext(pRuntime);
         pContext->OnField_Format(pFormField, Value, true);
-
         Optional<IJS_Runtime::JS_Error> err = pContext->RunScript(script);
         if (!err) {
-          sValue = Value;
+          sValue = std::move(Value);
           bFormatted = true;
         }
       }
diff --git a/fpdfsdk/fpdf_flatten.cpp b/fpdfsdk/fpdf_flatten.cpp
index 4b9e1f8..b9e29be 100644
--- a/fpdfsdk/fpdf_flatten.cpp
+++ b/fpdfsdk/fpdf_flatten.cpp
@@ -299,7 +299,7 @@
     while (i < INT_MAX) {
       ByteString sKey = ByteString::Format("FFT%d", i);
       if (!pPageXObject->KeyExist(sKey)) {
-        key = sKey;
+        key = std::move(sKey);
         break;
       }
       ++i;
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
index faa2fa5..386ea95 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
@@ -7,6 +7,7 @@
 #include "fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h"
 
 #include <memory>
+#include <utility>
 
 #include "core/fpdfapi/parser/cpdf_array.h"
 #include "core/fpdfapi/parser/cpdf_stream_acc.h"
@@ -848,27 +849,28 @@
     return false;
 
   auto pos = srcURL.Find(L'?');
-  WideString tmp;
-  if (!pos.has_value()) {
-    pos = srcURL.Find(L'@');
-    if (!pos.has_value())
-      return false;
 
-    tmp = srcURL.Right(csURL.GetLength() - 7);
-  } else {
-    tmp = srcURL.Left(pos.value());
-    tmp = tmp.Right(tmp.GetLength() - 7);
+  {
+    WideString tmp;
+    if (!pos.has_value()) {
+      pos = srcURL.Find(L'@');
+      if (!pos.has_value())
+        return false;
+
+      tmp = srcURL.Right(csURL.GetLength() - 7);
+    } else {
+      tmp = srcURL.Left(pos.value());
+      tmp = tmp.Right(tmp.GetLength() - 7);
+    }
+    tmp.Trim();
+    csToAddress = std::move(tmp);
   }
-  tmp.Trim();
-
-  csToAddress = tmp;
 
   srcURL = srcURL.Right(srcURL.GetLength() - (pos.value() + 1));
   while (!srcURL.IsEmpty()) {
     srcURL.Trim();
     pos = srcURL.Find(L'&');
-
-    tmp = (!pos.has_value()) ? srcURL : srcURL.Left(pos.value());
+    WideString tmp = (!pos.has_value()) ? srcURL : srcURL.Left(pos.value());
     tmp.Trim();
     if (tmp.GetLength() >= 3 && tmp.Left(3).CompareNoCase(L"cc=") == 0) {
       tmp = tmp.Right(tmp.GetLength() - 3);
diff --git a/fxbarcode/cbc_codabar.cpp b/fxbarcode/cbc_codabar.cpp
index 0795ff2..b32eafc 100644
--- a/fxbarcode/cbc_codabar.cpp
+++ b/fxbarcode/cbc_codabar.cpp
@@ -54,17 +54,13 @@
   BCFORMAT format = BCFORMAT_CODABAR;
   int32_t outWidth = 0;
   int32_t outHeight = 0;
-  WideString filtercontents = GetOnedCodaBarWriter()->FilterContents(contents);
-  ByteString byteString = filtercontents.UTF8Encode();
-  m_renderContents = filtercontents;
+  m_renderContents = GetOnedCodaBarWriter()->FilterContents(contents);
+  ByteString byteString = m_renderContents.UTF8Encode();
   auto* pWriter = GetOnedCodaBarWriter();
   std::unique_ptr<uint8_t, FxFreeDeleter> data(
       pWriter->Encode(byteString, format, outWidth, outHeight));
-  if (!data)
-    return false;
-
-  return pWriter->RenderResult(filtercontents.AsStringView(), data.get(),
-                               outWidth);
+  return data && pWriter->RenderResult(m_renderContents.AsStringView(),
+                                       data.get(), outWidth);
 }
 
 bool CBC_Codabar::RenderDevice(CFX_RenderDevice* device,
diff --git a/fxbarcode/cbc_code128.cpp b/fxbarcode/cbc_code128.cpp
index 7ba6235..8e83e22 100644
--- a/fxbarcode/cbc_code128.cpp
+++ b/fxbarcode/cbc_code128.cpp
@@ -47,15 +47,12 @@
   if (contents.GetLength() % 2 && pWriter->GetType() == BC_CODE128_C)
     content += '0';
 
-  WideString encodeContents = pWriter->FilterContents(content.AsStringView());
-  m_renderContents = encodeContents;
-  ByteString byteString = encodeContents.UTF8Encode();
+  m_renderContents = pWriter->FilterContents(content.AsStringView());
+  ByteString byteString = m_renderContents.UTF8Encode();
   std::unique_ptr<uint8_t, FxFreeDeleter> data(
       pWriter->Encode(byteString, format, outWidth, outHeight));
-  if (!data)
-    return false;
-  return pWriter->RenderResult(encodeContents.AsStringView(), data.get(),
-                               outWidth);
+  return data && pWriter->RenderResult(m_renderContents.AsStringView(),
+                                       data.get(), outWidth);
 }
 
 bool CBC_Code128::RenderDevice(CFX_RenderDevice* device,
diff --git a/fxbarcode/cbc_code39.cpp b/fxbarcode/cbc_code39.cpp
index 9715c25..52859e1 100644
--- a/fxbarcode/cbc_code39.cpp
+++ b/fxbarcode/cbc_code39.cpp
@@ -40,15 +40,12 @@
   int32_t outHeight = 0;
   auto* pWriter = GetOnedCode39Writer();
   WideString filtercontents = pWriter->FilterContents(contents);
-  WideString renderContents = pWriter->RenderTextContents(contents);
-  m_renderContents = renderContents;
+  m_renderContents = pWriter->RenderTextContents(contents);
   ByteString byteString = filtercontents.UTF8Encode();
   std::unique_ptr<uint8_t, FxFreeDeleter> data(
       pWriter->Encode(byteString, format, outWidth, outHeight));
-  if (!data)
-    return false;
-  return pWriter->RenderResult(renderContents.AsStringView(), data.get(),
-                               outWidth);
+  return data && pWriter->RenderResult(m_renderContents.AsStringView(),
+                                       data.get(), outWidth);
 }
 
 bool CBC_Code39::RenderDevice(CFX_RenderDevice* device,
diff --git a/fxbarcode/cbc_ean13.cpp b/fxbarcode/cbc_ean13.cpp
index 1672532..a111fdb 100644
--- a/fxbarcode/cbc_ean13.cpp
+++ b/fxbarcode/cbc_ean13.cpp
@@ -57,16 +57,13 @@
   BCFORMAT format = BCFORMAT_EAN_13;
   int32_t outWidth = 0;
   int32_t outHeight = 0;
-  WideString encodeContents = Preprocess(contents);
-  ByteString byteString = encodeContents.UTF8Encode();
-  m_renderContents = encodeContents;
+  m_renderContents = Preprocess(contents);
+  ByteString byteString = m_renderContents.UTF8Encode();
   auto* pWriter = GetOnedEAN13Writer();
   std::unique_ptr<uint8_t, FxFreeDeleter> data(
       pWriter->Encode(byteString, format, outWidth, outHeight));
-  if (!data)
-    return false;
-  return pWriter->RenderResult(encodeContents.AsStringView(), data.get(),
-                               outWidth);
+  return data && pWriter->RenderResult(m_renderContents.AsStringView(),
+                                       data.get(), outWidth);
 }
 
 bool CBC_EAN13::RenderDevice(CFX_RenderDevice* device,
diff --git a/fxbarcode/cbc_ean8.cpp b/fxbarcode/cbc_ean8.cpp
index 796f3a5..ce071af 100644
--- a/fxbarcode/cbc_ean8.cpp
+++ b/fxbarcode/cbc_ean8.cpp
@@ -55,16 +55,13 @@
   BCFORMAT format = BCFORMAT_EAN_8;
   int32_t outWidth = 0;
   int32_t outHeight = 0;
-  WideString encodeContents = Preprocess(contents);
-  ByteString byteString = encodeContents.UTF8Encode();
-  m_renderContents = encodeContents;
+  m_renderContents = Preprocess(contents);
+  ByteString byteString = m_renderContents.UTF8Encode();
   auto* pWriter = GetOnedEAN8Writer();
   std::unique_ptr<uint8_t, FxFreeDeleter> data(
       pWriter->Encode(byteString, format, outWidth, outHeight));
-  if (!data)
-    return false;
-  return pWriter->RenderResult(encodeContents.AsStringView(), data.get(),
-                               outWidth);
+  return data && pWriter->RenderResult(m_renderContents.AsStringView(),
+                                       data.get(), outWidth);
 }
 
 bool CBC_EAN8::RenderDevice(CFX_RenderDevice* device,
diff --git a/fxbarcode/cbc_upca.cpp b/fxbarcode/cbc_upca.cpp
index 69cedce..834eecf 100644
--- a/fxbarcode/cbc_upca.cpp
+++ b/fxbarcode/cbc_upca.cpp
@@ -56,18 +56,14 @@
   BCFORMAT format = BCFORMAT_UPC_A;
   int32_t outWidth = 0;
   int32_t outHeight = 0;
-  WideString encodeContents = Preprocess(contents);
-  ByteString byteString = encodeContents.UTF8Encode();
-  m_renderContents = encodeContents;
-
+  m_renderContents = Preprocess(contents);
+  ByteString byteString = m_renderContents.UTF8Encode();
   CBC_OnedUPCAWriter* pWriter = GetOnedUPCAWriter();
   pWriter->Init();
   std::unique_ptr<uint8_t, FxFreeDeleter> data(
       pWriter->Encode(byteString, format, outWidth, outHeight));
-  if (!data)
-    return false;
-  return pWriter->RenderResult(encodeContents.AsStringView(), data.get(),
-                               outWidth);
+  return data && pWriter->RenderResult(m_renderContents.AsStringView(),
+                                       data.get(), outWidth);
 }
 
 bool CBC_UPCA::RenderDevice(CFX_RenderDevice* device,
diff --git a/fxbarcode/datamatrix/BC_DefaultPlacement.cpp b/fxbarcode/datamatrix/BC_DefaultPlacement.cpp
index 3f1b358..24d81f1 100644
--- a/fxbarcode/datamatrix/BC_DefaultPlacement.cpp
+++ b/fxbarcode/datamatrix/BC_DefaultPlacement.cpp
@@ -21,19 +21,23 @@
  */
 
 #include "fxbarcode/datamatrix/BC_DefaultPlacement.h"
+
+#include <utility>
+
 #include "fxbarcode/datamatrix/BC_Encoder.h"
 
 CBC_DefaultPlacement::CBC_DefaultPlacement(WideString codewords,
                                            int32_t numcols,
-                                           int32_t numrows) {
-  m_codewords = codewords;
-  m_numcols = numcols;
-  m_numrows = numrows;
+                                           int32_t numrows)
+    : m_codewords(std::move(codewords)),
+      m_numrows(numrows),
+      m_numcols(numcols) {
   m_bits.resize(numcols * numrows);
   for (int32_t i = 0; i < numcols * numrows; i++) {
     m_bits[i] = (uint8_t)2;
   }
 }
+
 CBC_DefaultPlacement::~CBC_DefaultPlacement() {}
 
 int32_t CBC_DefaultPlacement::getNumrows() {
diff --git a/fxbarcode/datamatrix/BC_EncoderContext.cpp b/fxbarcode/datamatrix/BC_EncoderContext.cpp
index f5c2f4c..e72d1e4 100644
--- a/fxbarcode/datamatrix/BC_EncoderContext.cpp
+++ b/fxbarcode/datamatrix/BC_EncoderContext.cpp
@@ -22,6 +22,8 @@
 
 #include "fxbarcode/datamatrix/BC_EncoderContext.h"
 
+#include <utility>
+
 #include "fxbarcode/BC_UtilCodingConvert.h"
 #include "fxbarcode/common/BC_CommonBitMatrix.h"
 #include "fxbarcode/datamatrix/BC_Encoder.h"
@@ -43,7 +45,7 @@
     }
     sb += ch;
   }
-  m_msg = sb;
+  m_msg = std::move(sb);
   m_codewords.Reserve(m_msg.GetLength());
   m_allowRectangular = true;
   m_newEncoding = -1;
diff --git a/fxjs/cfxjse_formcalc_context.cpp b/fxjs/cfxjse_formcalc_context.cpp
index 181d9a1..3ed8a78 100644
--- a/fxjs/cfxjse_formcalc_context.cpp
+++ b/fxjs/cfxjse_formcalc_context.cpp
@@ -3807,16 +3807,14 @@
         wsPattern = L"num{" + wsPattern + L"}";
       } break;
       default: {
-        WideString wsTestPattern;
-        wsTestPattern = L"num{" + wsPattern + L"}";
+        WideString wsTestPattern = L"num{" + wsPattern + L"}";
         CXFA_LocaleValue tempLocaleValue(XFA_VT_FLOAT, wsValue, wsTestPattern,
                                          pLocale, pMgr);
         if (tempLocaleValue.IsValid()) {
-          wsPattern = wsTestPattern;
+          wsPattern = std::move(wsTestPattern);
           patternType = XFA_VT_FLOAT;
         } else {
-          wsTestPattern = L"text{" + wsPattern + L"}";
-          wsPattern = wsTestPattern;
+          wsPattern = L"text{" + wsPattern + L"}";
           patternType = XFA_VT_TEXT;
         }
       } break;
diff --git a/fxjs/cfxjse_resolveprocessor.cpp b/fxjs/cfxjse_resolveprocessor.cpp
index 46163b5..0419b79 100644
--- a/fxjs/cfxjse_resolveprocessor.cpp
+++ b/fxjs/cfxjse_resolveprocessor.cpp
@@ -179,7 +179,7 @@
   rndFind.m_dwStyles = rnd.m_dwStyles;
   rndFind.m_dwStyles |= XFA_RESOLVENODE_TagName;
   rndFind.m_dwStyles &= ~XFA_RESOLVENODE_Attributes;
-  rndFind.m_wsName = wsName;
+  rndFind.m_wsName = std::move(wsName);
   rndFind.m_uHashName = static_cast<XFA_HashCode>(
       FX_HashCode_GetW(rndFind.m_wsName.AsStringView(), false));
   rndFind.m_wsCondition = wsCondition;
@@ -255,10 +255,9 @@
     } else {
       rndFind.m_CurObject = pVariablesNode;
       SetStylesForChild(dwStyles, rndFind);
-      WideString wsSaveCondition = rndFind.m_wsCondition;
-      rndFind.m_wsCondition.clear();
+      WideString wsSaveCondition = std::move(rndFind.m_wsCondition);
       ResolveNormal(rndFind);
-      rndFind.m_wsCondition = wsSaveCondition;
+      rndFind.m_wsCondition = std::move(wsSaveCondition);
       rnd.m_Objects.insert(rnd.m_Objects.end(), rndFind.m_Objects.begin(),
                            rndFind.m_Objects.end());
       rndFind.m_Objects.clear();
@@ -290,11 +289,9 @@
         }
         rndFind.m_CurObject = child;
 
-        WideString wsSaveCondition = rndFind.m_wsCondition;
-        rndFind.m_wsCondition.clear();
+        WideString wsSaveCondition = std::move(rndFind.m_wsCondition);
         ResolveNormal(rndFind);
-
-        rndFind.m_wsCondition = wsSaveCondition;
+        rndFind.m_wsCondition = std::move(wsSaveCondition);
         rnd.m_Objects.insert(rnd.m_Objects.end(), rndFind.m_Objects.begin(),
                              rndFind.m_Objects.end());
         rndFind.m_Objects.clear();
@@ -425,15 +422,12 @@
       }
       if (bInnerSearch) {
         rndFind.m_CurObject = child;
-        WideString wsOriginCondition = rndFind.m_wsCondition;
-        rndFind.m_wsCondition.clear();
-
+        WideString wsOriginCondition = std::move(rndFind.m_wsCondition);
         uint32_t dwOriginStyle = rndFind.m_dwStyles;
         rndFind.m_dwStyles = dwOriginStyle | XFA_RESOLVENODE_ALL;
         ResolveNormal(rndFind);
-
         rndFind.m_dwStyles = dwOriginStyle;
-        rndFind.m_wsCondition = wsOriginCondition;
+        rndFind.m_wsCondition = std::move(wsOriginCondition);
         rnd.m_Objects.insert(rnd.m_Objects.end(), rndFind.m_Objects.begin(),
                              rndFind.m_Objects.end());
         rndFind.m_Objects.clear();
diff --git a/fxjs/cjs_globaldata.cpp b/fxjs/cjs_globaldata.cpp
index 59ada3b..de240cf 100644
--- a/fxjs/cjs_globaldata.cpp
+++ b/fxjs/cjs_globaldata.cpp
@@ -90,9 +90,8 @@
   return iter != m_arrayGlobalData.end() ? iter->get() : nullptr;
 }
 
-void CJS_GlobalData::SetGlobalVariableNumber(const ByteString& propname,
+void CJS_GlobalData::SetGlobalVariableNumber(ByteString sPropName,
                                              double dData) {
-  ByteString sPropName(propname);
   if (!TrimPropName(&sPropName))
     return;
 
@@ -102,15 +101,14 @@
     return;
   }
   auto pNewData = pdfium::MakeUnique<CJS_GlobalData_Element>();
-  pNewData->data.sKey = sPropName;
+  pNewData->data.sKey = std::move(sPropName);
   pNewData->data.nType = JS_GlobalDataType::NUMBER;
   pNewData->data.dData = dData;
   m_arrayGlobalData.push_back(std::move(pNewData));
 }
 
-void CJS_GlobalData::SetGlobalVariableBoolean(const ByteString& propname,
+void CJS_GlobalData::SetGlobalVariableBoolean(ByteString sPropName,
                                               bool bData) {
-  ByteString sPropName(propname);
   if (!TrimPropName(&sPropName))
     return;
 
@@ -120,15 +118,14 @@
     return;
   }
   auto pNewData = pdfium::MakeUnique<CJS_GlobalData_Element>();
-  pNewData->data.sKey = sPropName;
+  pNewData->data.sKey = std::move(sPropName);
   pNewData->data.nType = JS_GlobalDataType::BOOLEAN;
   pNewData->data.bData = bData;
   m_arrayGlobalData.push_back(std::move(pNewData));
 }
 
-void CJS_GlobalData::SetGlobalVariableString(const ByteString& propname,
+void CJS_GlobalData::SetGlobalVariableString(ByteString sPropName,
                                              const ByteString& sData) {
-  ByteString sPropName(propname);
   if (!TrimPropName(&sPropName))
     return;
 
@@ -138,16 +135,15 @@
     return;
   }
   auto pNewData = pdfium::MakeUnique<CJS_GlobalData_Element>();
-  pNewData->data.sKey = sPropName;
+  pNewData->data.sKey = std::move(sPropName);
   pNewData->data.nType = JS_GlobalDataType::STRING;
   pNewData->data.sData = sData;
   m_arrayGlobalData.push_back(std::move(pNewData));
 }
 
 void CJS_GlobalData::SetGlobalVariableObject(
-    const ByteString& propname,
+    ByteString sPropName,
     const CJS_GlobalVariableArray& array) {
-  ByteString sPropName(propname);
   if (!TrimPropName(&sPropName))
     return;
 
@@ -157,14 +153,13 @@
     return;
   }
   auto pNewData = pdfium::MakeUnique<CJS_GlobalData_Element>();
-  pNewData->data.sKey = sPropName;
+  pNewData->data.sKey = std::move(sPropName);
   pNewData->data.nType = JS_GlobalDataType::OBJECT;
   pNewData->data.objData.Copy(array);
   m_arrayGlobalData.push_back(std::move(pNewData));
 }
 
-void CJS_GlobalData::SetGlobalVariableNull(const ByteString& propname) {
-  ByteString sPropName(propname);
+void CJS_GlobalData::SetGlobalVariableNull(ByteString sPropName) {
   if (!TrimPropName(&sPropName))
     return;
 
@@ -173,14 +168,13 @@
     return;
   }
   auto pNewData = pdfium::MakeUnique<CJS_GlobalData_Element>();
-  pNewData->data.sKey = sPropName;
+  pNewData->data.sKey = std::move(sPropName);
   pNewData->data.nType = JS_GlobalDataType::NULLOBJ;
   m_arrayGlobalData.push_back(std::move(pNewData));
 }
 
-bool CJS_GlobalData::SetGlobalVariablePersistent(const ByteString& propname,
+bool CJS_GlobalData::SetGlobalVariablePersistent(ByteString sPropName,
                                                  bool bPersistent) {
-  ByteString sPropName(propname);
   if (!TrimPropName(&sPropName))
     return false;
 
@@ -192,8 +186,7 @@
   return true;
 }
 
-bool CJS_GlobalData::DeleteGlobalVariable(const ByteString& propname) {
-  ByteString sPropName(propname);
+bool CJS_GlobalData::DeleteGlobalVariable(ByteString sPropName) {
   if (!TrimPropName(&sPropName))
     return false;
 
diff --git a/fxjs/cjs_globaldata.h b/fxjs/cjs_globaldata.h
index b9a4b21..9ce4358 100644
--- a/fxjs/cjs_globaldata.h
+++ b/fxjs/cjs_globaldata.h
@@ -29,16 +29,14 @@
   static CJS_GlobalData* GetRetainedInstance(CPDFSDK_FormFillEnvironment* pApp);
   void Release();
 
-  void SetGlobalVariableNumber(const ByteString& propname, double dData);
-  void SetGlobalVariableBoolean(const ByteString& propname, bool bData);
-  void SetGlobalVariableString(const ByteString& propname,
-                               const ByteString& sData);
-  void SetGlobalVariableObject(const ByteString& propname,
+  void SetGlobalVariableNumber(ByteString propname, double dData);
+  void SetGlobalVariableBoolean(ByteString propname, bool bData);
+  void SetGlobalVariableString(ByteString propname, const ByteString& sData);
+  void SetGlobalVariableObject(ByteString propname,
                                const CJS_GlobalVariableArray& array);
-  void SetGlobalVariableNull(const ByteString& propname);
-  bool SetGlobalVariablePersistent(const ByteString& propname,
-                                   bool bPersistent);
-  bool DeleteGlobalVariable(const ByteString& propname);
+  void SetGlobalVariableNull(ByteString propname);
+  bool SetGlobalVariablePersistent(ByteString propname, bool bPersistent);
+  bool DeleteGlobalVariable(ByteString propname);
 
   int32_t GetSize() const;
   CJS_GlobalData_Element* GetAt(int index) const;
diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp
index 908611b..4630445 100644
--- a/fxjs/cjs_publicmethods.cpp
+++ b/fxjs/cjs_publicmethods.cpp
@@ -14,6 +14,7 @@
 #include <limits>
 #include <sstream>
 #include <string>
+#include <utility>
 #include <vector>
 
 #include "core/fpdfdoc/cpdf_interform.h"
@@ -1192,13 +1193,12 @@
   WideString sTemp;
   for (const auto& c : strValue) {
     if (c == L' ' || c == L':') {
-      wsArray.push_back(sTemp);
-      sTemp.clear();
+      wsArray.push_back(std::move(sTemp));
       continue;
     }
     sTemp += c;
   }
-  wsArray.push_back(sTemp);
+  wsArray.push_back(std::move(sTemp));
   if (wsArray.size() != 8)
     return 0;
 
@@ -1471,7 +1471,7 @@
     }
     iIndexMask++;
   }
-  wideChange = wChange;
+  wideChange = std::move(wChange);
   return CJS_Return();
 }
 
diff --git a/fxjs/xfa/cjx_layoutpseudomodel.cpp b/fxjs/xfa/cjx_layoutpseudomodel.cpp
index a5dcf98..e448aea 100644
--- a/fxjs/xfa/cjx_layoutpseudomodel.cpp
+++ b/fxjs/xfa/cjx_layoutpseudomodel.cpp
@@ -7,6 +7,7 @@
 #include "fxjs/xfa/cjx_layoutpseudomodel.h"
 
 #include <set>
+#include <utility>
 
 #include "core/fxcrt/fx_coordinates.h"
 #include "fxjs/cfxjse_engine.h"
@@ -84,10 +85,9 @@
   if (params.size() >= 2) {
     WideString tmp_unit = runtime->ToWideString(params[1]);
     if (!tmp_unit.IsEmpty())
-      unit = tmp_unit;
+      unit = std::move(tmp_unit);
   }
   int32_t iIndex = params.size() >= 3 ? runtime->ToInt32(params[2]) : 0;
-
   CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor();
   if (!pDocLayout)
     return CJS_Return();
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index a6b1d12..2cf6f67 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -1175,9 +1175,9 @@
   WideString wsSOM;
   if (!wsValue.IsEmpty()) {
     if (wsValue[0] == '#')
-      wsID = WideString(wsValue.c_str() + 1, wsValue.GetLength() - 1);
+      wsID = wsValue.Mid(1, wsValue.GetLength() - 1);
     else
-      wsSOM = wsValue;
+      wsSOM = std::move(wsValue);
   }
 
   CXFA_Node* pProtoNode = nullptr;
diff --git a/xfa/fgas/crt/cfgas_formatstring.cpp b/xfa/fgas/crt/cfgas_formatstring.cpp
index 0162100..e9d065d 100644
--- a/xfa/fgas/crt/cfgas_formatstring.cpp
+++ b/xfa/fgas/crt/cfgas_formatstring.cpp
@@ -7,6 +7,7 @@
 #include "xfa/fgas/crt/cfgas_formatstring.h"
 
 #include <algorithm>
+#include <utility>
 #include <vector>
 
 #include "core/fxcrt/cfx_decimal.h"
@@ -1647,11 +1648,11 @@
       bBraceOpen = false;
       if (!wsTempPattern.IsEmpty()) {
         if (eCategory == FX_LOCALECATEGORY_Time)
-          *wsTimePattern = wsTempPattern;
+          *wsTimePattern = std::move(wsTempPattern);
         else if (eCategory == FX_LOCALECATEGORY_Date)
-          *wsDatePattern = wsTempPattern;
-
-        wsTempPattern.clear();
+          *wsDatePattern = std::move(wsTempPattern);
+        else
+          wsTempPattern.clear();
       }
     } else {
       wsTempPattern += pStr[ccf];
@@ -2246,14 +2247,13 @@
     return false;
 
   if (eCategory == FX_DATETIMETYPE_Unknown) {
-    if (eDateTimeType == FX_DATETIMETYPE_Time) {
-      wsTimePattern = wsDatePattern;
-      wsDatePattern.clear();
-    }
+    if (eDateTimeType == FX_DATETIMETYPE_Time)
+      wsTimePattern = std::move(wsDatePattern);
+
     eCategory = eDateTimeType;
+    if (eCategory == FX_DATETIMETYPE_Unknown)
+      return false;
   }
-  if (eCategory == FX_DATETIMETYPE_Unknown)
-    return false;
 
   CFX_DateTime dt;
   auto iT = wsSrcDateTime.Find(L"T");
diff --git a/xfa/fwl/cfwl_listbox.cpp b/xfa/fwl/cfwl_listbox.cpp
index 0b0043b..5f683d3 100644
--- a/xfa/fwl/cfwl_listbox.cpp
+++ b/xfa/fwl/cfwl_listbox.cpp
@@ -458,7 +458,7 @@
   textParam.m_pGraphics = pGraphics;
   textParam.m_matrix.Concat(*pMatrix);
   textParam.m_rtPart = rtText;
-  textParam.m_wsText = wsText;
+  textParam.m_wsText = std::move(wsText);
   textParam.m_dwTTOStyles = m_dwTTOStyles;
   textParam.m_iTTOAlign = m_iTTOAligns;
   textParam.m_bMaximize = true;
diff --git a/xfa/fxfa/cxfa_ffcombobox.cpp b/xfa/fxfa/cxfa_ffcombobox.cpp
index a150101..893ee60 100644
--- a/xfa/fxfa/cxfa_ffcombobox.cpp
+++ b/xfa/fxfa/cxfa_ffcombobox.cpp
@@ -120,7 +120,7 @@
   if (m_pNode->GetValue(XFA_VALUEPICTURE_Raw) == wsText)
     return false;
 
-  m_wsNewValue = wsText;
+  m_wsNewValue = std::move(wsText);
   return true;
 }
 
diff --git a/xfa/fxfa/cxfa_fftextedit.cpp b/xfa/fxfa/cxfa_fftextedit.cpp
index a8080d1..81bc9b3 100644
--- a/xfa/fxfa/cxfa_fftextedit.cpp
+++ b/xfa/fxfa/cxfa_fftextedit.cpp
@@ -313,7 +313,7 @@
   // Copy the data back out of the EventParam and into the TextChanged event so
   // it can propagate back to the calling widget.
   event->cancelled = eParam.m_bCancelAction;
-  event->change_text = eParam.m_wsChange;
+  event->change_text = std::move(eParam.m_wsChange);
   event->selection_start = static_cast<size_t>(eParam.m_iSelStart);
   event->selection_end = static_cast<size_t>(eParam.m_iSelEnd);
 }
diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp
index 6f3e56c..8bafc7f 100644
--- a/xfa/fxfa/parser/cxfa_document_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_document_parser.cpp
@@ -138,7 +138,7 @@
   WideString wsAttrName(wsAttributeName);
   auto pos = wsAttrName.Find(L':', 0);
   if (!pos.has_value()) {
-    wsLocalAttrName = wsAttrName;
+    wsLocalAttrName = std::move(wsAttrName);
     return false;
   }
   wsLocalAttrName = wsAttrName.Right(wsAttrName.GetLength() - pos.value() - 1);
@@ -254,7 +254,7 @@
         if (IsStringAllWhitespace(wsText))
           continue;
 
-        wsOutput = wsText;
+        wsOutput = std::move(wsText);
         break;
       }
       default:
diff --git a/xfa/fxfa/parser/cxfa_localevalue.cpp b/xfa/fxfa/parser/cxfa_localevalue.cpp
index 78f6b3b..3a55045 100644
--- a/xfa/fxfa/parser/cxfa_localevalue.cpp
+++ b/xfa/fxfa/parser/cxfa_localevalue.cpp
@@ -6,6 +6,7 @@
 
 #include "xfa/fxfa/parser/cxfa_localevalue.h"
 
+#include <utility>
 #include <vector>
 
 #include "core/fxcrt/fx_extension.h"
@@ -618,7 +619,7 @@
         WideString fNum;
         bRet = pFormat->ParseNum(wsValue, wsFormat, &fNum);
         if (bRet)
-          m_wsValue = fNum;
+          m_wsValue = std::move(fNum);
         break;
       }
       case FX_LOCALECATEGORY_Text:
diff --git a/xfa/fxfa/parser/cxfa_nodehelper.cpp b/xfa/fxfa/parser/cxfa_nodehelper.cpp
index eea054a..7eddddf 100644
--- a/xfa/fxfa/parser/cxfa_nodehelper.cpp
+++ b/xfa/fxfa/parser/cxfa_nodehelper.cpp
@@ -6,6 +6,8 @@
 
 #include "xfa/fxfa/parser/cxfa_nodehelper.h"
 
+#include <utility>
+
 #include "core/fxcrt/fx_extension.h"
 #include "fxjs/cfxjse_engine.h"
 #include "fxjs/xfa/cjx_object.h"
@@ -237,14 +239,13 @@
   WideString wsName;
   if (bIsAllPath) {
     wsName = GetNameExpression(refNode, false, eLogicType);
-    WideString wsParent;
     CXFA_Node* parent =
         ResolveNodes_GetParent(refNode, XFA_LOGIC_NoTransparent);
     while (parent) {
-      wsParent = GetNameExpression(parent, false, eLogicType);
+      WideString wsParent = GetNameExpression(parent, false, eLogicType);
       wsParent += L".";
       wsParent += wsName;
-      wsName = wsParent;
+      wsName = std::move(wsParent);
       parent = ResolveNodes_GetParent(parent, XFA_LOGIC_NoTransparent);
     }
     return wsName;