diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-06-19 17:33:32 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-06-19 17:33:32 +0000 |
commit | e005dc33c31a2e701e1af3a0a3e5775cabbf1ddd (patch) | |
tree | 6cf7623219078464910ee438311e24121c8af2a0 | |
parent | ed1c58049f0c164969946b6ad0ff06d952ab1949 (diff) | |
download | pdfium-e005dc33c31a2e701e1af3a0a3e5775cabbf1ddd.tar.xz |
Move fxcrt::{Byte,Wide}Strings with std::move().chromium/3466
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>
34 files changed, 139 insertions, 165 deletions
diff --git a/core/fpdfapi/font/cpdf_tounicodemap.cpp b/core/fpdfapi/font/cpdf_tounicodemap.cpp index 7b5936c31e..e8917310a2 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 @@ void CPDF_ToUnicodeMap::Load(const CPDF_Stream* pStream) { 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 e17a30560f..deddf3cc3e 100644 --- a/core/fpdfapi/page/cpdf_contentmark.cpp +++ b/core/fpdfapi/page/cpdf_contentmark.cpp @@ -31,10 +31,10 @@ int CPDF_ContentMark::GetMarkedContentID() const { 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 @@ int CPDF_ContentMark::MarkData::GetMarkedContentID() const { 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 1d8b9e2515..494c20630b 100644 --- a/core/fpdfapi/page/cpdf_contentmark.h +++ b/core/fpdfapi/page/cpdf_contentmark.h @@ -25,9 +25,7 @@ class CPDF_ContentMark { 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 @@ class CPDF_ContentMark { 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 0cc81f1e9b..2fbb73b6b2 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -184,7 +184,7 @@ void ReplaceAbbr(CPDF_Object* pObj) { 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 @@ void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() { 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 @@ void CPDF_StreamContentParser::Handle_ExecuteXObject() { 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 @@ void CPDF_StreamContentParser::Handle_ShowText_Positioning() { 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 aafb812234..0ca9b4eab2 100644 --- a/core/fpdfapi/parser/fpdf_parser_decode.cpp +++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp @@ -404,7 +404,7 @@ bool PDF_DataDecode(const uint8_t* src_buf, 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 2100d4ecee..a80b0294c1 100644 --- a/core/fpdfdoc/cpdf_formcontrol.cpp +++ b/core/fpdfdoc/cpdf_formcontrol.cpp @@ -149,11 +149,10 @@ bool CPDF_FormControl::IsDefaultChecked() const { 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 8dcc9e68b6..2f05ad8732 100644 --- a/core/fpdfdoc/cpdf_formfield.cpp +++ b/core/fpdfdoc/cpdf_formfield.cpp @@ -92,7 +92,7 @@ WideString FPDF_GetFullName(CPDF_Dictionary* pFieldDict) { 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 de3770901b..b18310cfde 100644 --- a/core/fpdfdoc/cpdf_interform.cpp +++ b/core/fpdfdoc/cpdf_interform.cpp @@ -206,8 +206,7 @@ bool FindFont(CPDF_Dictionary* pFormDict, if (!pFont) continue; - ByteString csBaseFont; - csBaseFont = pFont->GetBaseFont(); + ByteString csBaseFont = pFont->GetBaseFont(); csBaseFont.Remove(' '); if (csBaseFont == csFontName) { *csNameTag = csKey; @@ -228,7 +227,7 @@ void AddFont(CPDF_Dictionary*& pFormDict, ByteString csTag; if (FindFont(pFormDict, pFont, &csTag)) { - *csNameTag = csTag; + *csNameTag = std::move(csTag); return; } if (!pFormDict) @@ -261,7 +260,7 @@ CPDF_Font* AddNativeFont(CPDF_Dictionary*& pFormDict, 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 24c028fb61..d8fc0d88ba 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 @@ CPDF_StructElement::CPDF_StructElement(CPDF_StructTree* pTree, 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 1e247465c8..379a8b999d 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 CPDFSDK_InterForm::OnFormat(CPDF_FormField* pFormField, 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 4b9e1f8a9d..b9e29be8b4 100644 --- a/fpdfsdk/fpdf_flatten.cpp +++ b/fpdfsdk/fpdf_flatten.cpp @@ -299,7 +299,7 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFPage_Flatten(FPDF_PAGE page, int nFlag) { 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 faa2fa5e42..386ea95f5e 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 @@ bool CPDFXFA_DocEnvironment::MailToInfo(WideString& csURL, 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); - } - tmp.Trim(); + { + WideString tmp; + if (!pos.has_value()) { + pos = srcURL.Find(L'@'); + if (!pos.has_value()) + return false; - csToAddress = tmp; + tmp = srcURL.Right(csURL.GetLength() - 7); + } else { + tmp = srcURL.Left(pos.value()); + tmp = tmp.Right(tmp.GetLength() - 7); + } + tmp.Trim(); + csToAddress = std::move(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 0795ff295d..b32eafc376 100644 --- a/fxbarcode/cbc_codabar.cpp +++ b/fxbarcode/cbc_codabar.cpp @@ -54,17 +54,13 @@ bool CBC_Codabar::Encode(const WideStringView& contents) { 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 7ba623542d..8e83e2251c 100644 --- a/fxbarcode/cbc_code128.cpp +++ b/fxbarcode/cbc_code128.cpp @@ -47,15 +47,12 @@ bool CBC_Code128::Encode(const WideStringView& contents) { 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 9715c25828..52859e14c5 100644 --- a/fxbarcode/cbc_code39.cpp +++ b/fxbarcode/cbc_code39.cpp @@ -40,15 +40,12 @@ bool CBC_Code39::Encode(const WideStringView& contents) { 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 16725323f4..a111fdbfb6 100644 --- a/fxbarcode/cbc_ean13.cpp +++ b/fxbarcode/cbc_ean13.cpp @@ -57,16 +57,13 @@ bool CBC_EAN13::Encode(const WideStringView& contents) { 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 796f3a526b..ce071af2ce 100644 --- a/fxbarcode/cbc_ean8.cpp +++ b/fxbarcode/cbc_ean8.cpp @@ -55,16 +55,13 @@ bool CBC_EAN8::Encode(const WideStringView& contents) { 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 69cedce580..834eecf1ec 100644 --- a/fxbarcode/cbc_upca.cpp +++ b/fxbarcode/cbc_upca.cpp @@ -56,18 +56,14 @@ bool CBC_UPCA::Encode(const WideStringView& contents) { 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 3f1b35864f..24d81f1bb3 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 f5c2f4c1fc..e72d1e4640 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 @@ CBC_EncoderContext::CBC_EncoderContext(const WideString& msg, } 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 181d9a1dce..3ed8a78da3 100644 --- a/fxjs/cfxjse_formcalc_context.cpp +++ b/fxjs/cfxjse_formcalc_context.cpp @@ -3807,16 +3807,14 @@ void CFXJSE_FormCalcContext::Format(CFXJSE_Value* pThis, 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 46163b55fc..0419b79053 100644 --- a/fxjs/cfxjse_resolveprocessor.cpp +++ b/fxjs/cfxjse_resolveprocessor.cpp @@ -179,7 +179,7 @@ bool CFXJSE_ResolveProcessor::ResolveNumberSign(CFXJSE_ResolveNodeData& rnd) { 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 @@ bool CFXJSE_ResolveProcessor::ResolveNormal(CFXJSE_ResolveNodeData& rnd) { } 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 @@ bool CFXJSE_ResolveProcessor::ResolveNormal(CFXJSE_ResolveNodeData& rnd) { } 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 @@ bool CFXJSE_ResolveProcessor::ResolveNormal(CFXJSE_ResolveNodeData& rnd) { } 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 59ada3b8d1..de240cf453 100644 --- a/fxjs/cjs_globaldata.cpp +++ b/fxjs/cjs_globaldata.cpp @@ -90,9 +90,8 @@ CJS_GlobalData_Element* CJS_GlobalData::GetGlobalVariable( 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 @@ void CJS_GlobalData::SetGlobalVariableNumber(const ByteString& propname, 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 @@ void CJS_GlobalData::SetGlobalVariableBoolean(const ByteString& propname, 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 @@ void CJS_GlobalData::SetGlobalVariableString(const ByteString& propname, 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 @@ void CJS_GlobalData::SetGlobalVariableObject( 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 @@ void CJS_GlobalData::SetGlobalVariableNull(const ByteString& propname) { 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 @@ bool CJS_GlobalData::SetGlobalVariablePersistent(const ByteString& propname, 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 b9a4b2123e..9ce4358fd4 100644 --- a/fxjs/cjs_globaldata.h +++ b/fxjs/cjs_globaldata.h @@ -29,16 +29,14 @@ class CJS_GlobalData { 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 908611b0d6..4630445a35 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 @@ double CJS_PublicMethods::MakeInterDate(const WideString& strValue) { 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 @@ CJS_Return CJS_PublicMethods::AFSpecial_KeystrokeEx( } 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 a5dcf98b00..e448aea252 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 @@ CJS_Return CJX_LayoutPseudoModel::HWXY( 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 a6b1d122ae..2cf6f6755d 100644 --- a/fxjs/xfa/cjx_object.cpp +++ b/fxjs/xfa/cjx_object.cpp @@ -1175,9 +1175,9 @@ void CJX_Object::Script_Attribute_String(CFXJSE_Value* pValue, 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 0162100949..e9d065d124 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 @@ FX_DATETIMETYPE CFGAS_FormatString::GetDateTimeFormat( 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 @@ bool CFGAS_FormatString::FormatDateTime(const WideString& wsSrcDateTime, 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 0b0043b3cc..5f683d3e11 100644 --- a/xfa/fwl/cfwl_listbox.cpp +++ b/xfa/fwl/cfwl_listbox.cpp @@ -458,7 +458,7 @@ void CFWL_ListBox::DrawItem(CXFA_Graphics* pGraphics, 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 a150101efb..893ee60aa1 100644 --- a/xfa/fxfa/cxfa_ffcombobox.cpp +++ b/xfa/fxfa/cxfa_ffcombobox.cpp @@ -120,7 +120,7 @@ bool CXFA_FFComboBox::IsDataChanged() { 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 a8080d13d5..81bc9b3816 100644 --- a/xfa/fxfa/cxfa_fftextedit.cpp +++ b/xfa/fxfa/cxfa_fftextedit.cpp @@ -313,7 +313,7 @@ void CXFA_FFTextEdit::OnTextWillChange(CFWL_Widget* pWidget, // 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 6f3e56ce4c..8bafc7f078 100644 --- a/xfa/fxfa/parser/cxfa_document_parser.cpp +++ b/xfa/fxfa/parser/cxfa_document_parser.cpp @@ -138,7 +138,7 @@ bool GetAttributeLocalName(const WideStringView& wsAttributeName, 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 @@ void ConvertXMLToPlainText(CFX_XMLElement* pRootXMLNode, WideString& wsOutput) { 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 78f6b3b5e4..3a55045905 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 @@ bool CXFA_LocaleValue::ParsePatternValue(const WideString& wsValue, 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 eea054a169..7eddddf37b 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 CXFA_NodeHelper::GetNameExpression(CXFA_Node* refNode, 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; |