From 9d7c7ff0a5f0da6e7574557e5a8e82b9b5b7c1ae Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 16 Mar 2018 19:25:30 +0000 Subject: Make more variables const-ref. Found by ClangTidy. BUG=pdfium:1040 Change-Id: I6d7cb26ae2d12f5650f73596d0b991234b076f57 Reviewed-on: https://pdfium-review.googlesource.com/28712 Reviewed-by: Henrique Nakashima Commit-Queue: Lei Zhang --- core/fxcrt/xml/cfx_xmlinstruction.cpp | 2 +- core/fxcrt/xml/cfx_xmlnode.cpp | 18 ++++++++++-------- core/fxcrt/xml/cfx_xmlnode.h | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) (limited to 'core/fxcrt') diff --git a/core/fxcrt/xml/cfx_xmlinstruction.cpp b/core/fxcrt/xml/cfx_xmlinstruction.cpp index dabd538b4b..35b68e4d7d 100644 --- a/core/fxcrt/xml/cfx_xmlinstruction.cpp +++ b/core/fxcrt/xml/cfx_xmlinstruction.cpp @@ -62,7 +62,7 @@ void CFX_XMLInstruction::Save( AttributeToString(it.first, it.second).AsStringView()); } - for (auto target : m_TargetData) { + for (const WideString& target : m_TargetData) { WideString ws = L" \""; ws += target; ws += L"\""; diff --git a/core/fxcrt/xml/cfx_xmlnode.cpp b/core/fxcrt/xml/cfx_xmlnode.cpp index 1851a4d81e..5e787ed2b9 100644 --- a/core/fxcrt/xml/cfx_xmlnode.cpp +++ b/core/fxcrt/xml/cfx_xmlnode.cpp @@ -110,16 +110,18 @@ std::unique_ptr CFX_XMLNode::Clone() { void CFX_XMLNode::Save(const RetainPtr& pXMLStream) {} -WideString CFX_XMLNode::EncodeEntities(WideString value) { - value.Replace(L"&", L"&"); - value.Replace(L"<", L"<"); - value.Replace(L">", L">"); - value.Replace(L"\'", L"'"); - value.Replace(L"\"", L"""); - return value; +WideString CFX_XMLNode::EncodeEntities(const WideString& value) { + WideString ret = value; + ret.Replace(L"&", L"&"); + ret.Replace(L"<", L"<"); + ret.Replace(L">", L">"); + ret.Replace(L"\'", L"'"); + ret.Replace(L"\"", L"""); + return ret; } -WideString CFX_XMLNode::AttributeToString(WideString name, WideString value) { +WideString CFX_XMLNode::AttributeToString(const WideString& name, + const WideString& value) { WideString ret = L" "; ret += name; ret += L"=\""; diff --git a/core/fxcrt/xml/cfx_xmlnode.h b/core/fxcrt/xml/cfx_xmlnode.h index cf2158af5b..76625e3ca2 100644 --- a/core/fxcrt/xml/cfx_xmlnode.h +++ b/core/fxcrt/xml/cfx_xmlnode.h @@ -45,8 +45,8 @@ class CFX_XMLNode { void DeleteChildren(); protected: - WideString AttributeToString(WideString name, WideString value); - WideString EncodeEntities(WideString value); + WideString AttributeToString(const WideString& name, const WideString& value); + WideString EncodeEntities(const WideString& value); private: CFX_XMLNode* parent_ = nullptr; -- cgit v1.2.3