From e005dc33c31a2e701e1af3a0a3e5775cabbf1ddd Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 19 Jun 2018 17:33:32 +0000 Subject: 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 Reviewed-by: Tom Sepez Commit-Queue: Tom Sepez --- xfa/fgas/crt/cfgas_formatstring.cpp | 20 ++++++++++---------- xfa/fwl/cfwl_listbox.cpp | 2 +- xfa/fxfa/cxfa_ffcombobox.cpp | 2 +- xfa/fxfa/cxfa_fftextedit.cpp | 2 +- xfa/fxfa/parser/cxfa_document_parser.cpp | 4 ++-- xfa/fxfa/parser/cxfa_localevalue.cpp | 3 ++- xfa/fxfa/parser/cxfa_nodehelper.cpp | 7 ++++--- 7 files changed, 21 insertions(+), 19 deletions(-) (limited to 'xfa') 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 +#include #include #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(eParam.m_iSelStart); event->selection_end = static_cast(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 #include #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 + #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; -- cgit v1.2.3