From 135c6601bd9d12bd935371d3122f8e75391de75b Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 21 Nov 2017 18:07:00 +0000 Subject: Add {Byte/Wide}String::Trim(). So callers no longer have to call str.TrimLeft(); str.TrimRight(); Change-Id: If931eaa8d891f487b9618ebbeee5ee294e807846 Reviewed-on: https://pdfium-review.googlesource.com/18990 Reviewed-by: dsinclair Commit-Queue: Lei Zhang --- fxjs/cfxjse_formcalc_context.cpp | 3 +-- fxjs/cfxjse_resolveprocessor.cpp | 9 +++------ fxjs/cjs_document.cpp | 6 ++---- fxjs/cjs_globaldata.cpp | 3 +-- fxjs/cjs_publicmethods.cpp | 3 +-- fxjs/cjx_hostpseudomodel.cpp | 3 +-- 6 files changed, 9 insertions(+), 18 deletions(-) (limited to 'fxjs') diff --git a/fxjs/cfxjse_formcalc_context.cpp b/fxjs/cfxjse_formcalc_context.cpp index f3c4ebe462..d34493a7b2 100644 --- a/fxjs/cfxjse_formcalc_context.cpp +++ b/fxjs/cfxjse_formcalc_context.cpp @@ -534,8 +534,7 @@ ByteString GUIDString(bool bSeparator) { double ByteStringToDouble(const ByteStringView& szStringVal) { WideString wsValue = WideString::FromUTF8(szStringVal); - wsValue.TrimLeft(); - wsValue.TrimRight(); + wsValue.Trim(); int32_t cc = 0; bool bNegative = false; diff --git a/fxjs/cfxjse_resolveprocessor.cpp b/fxjs/cfxjse_resolveprocessor.cpp index 7802957c7c..ef7ddc10fb 100644 --- a/fxjs/cfxjse_resolveprocessor.cpp +++ b/fxjs/cfxjse_resolveprocessor.cpp @@ -582,11 +582,9 @@ int32_t CFXJSE_ResolveProcessor::GetFilter(const WideStringView& wsExpression, return -1; wsName.ReleaseBuffer(nNameCount); - wsName.TrimLeft(); - wsName.TrimRight(); + wsName.Trim(); wsCondition.ReleaseBuffer(nConditionCount); - wsCondition.TrimLeft(); - wsCondition.TrimRight(); + wsCondition.Trim(); rnd.m_uHashName = static_cast(FX_HashCode_GetW(wsName.AsStringView(), false)); return nStart; @@ -700,8 +698,7 @@ void CFXJSE_ResolveProcessor::FilterCondition(CFXJSE_ResolveNodeData& rnd, } } int32_t iFoundCount = pdfium::CollectionSize(rnd.m_Objects); - wsCondition.TrimLeft(); - wsCondition.TrimRight(); + wsCondition.Trim(); int32_t iLen = wsCondition.GetLength(); if (!iLen) { if (rnd.m_dwStyles & XFA_RESOLVENODE_ALL) { diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp index 862055a7ff..4885d68e1b 100644 --- a/fxjs/cjs_document.cpp +++ b/fxjs/cjs_document.cpp @@ -1264,10 +1264,8 @@ CJS_Return Document::getPageNthWord( } } - if (bStrip) { - swRet.TrimLeft(); - swRet.TrimRight(); - } + if (bStrip) + swRet.Trim(); return CJS_Return(pRuntime->NewString(swRet.c_str())); } diff --git a/fxjs/cjs_globaldata.cpp b/fxjs/cjs_globaldata.cpp index 3f962734db..a78bce55c3 100644 --- a/fxjs/cjs_globaldata.cpp +++ b/fxjs/cjs_globaldata.cpp @@ -33,8 +33,7 @@ const uint8_t JS_RC4KEY[] = { // Returns true if non-empty, setting sPropName bool TrimPropName(ByteString* sPropName) { - sPropName->TrimLeft(); - sPropName->TrimRight(); + sPropName->Trim(); return sPropName->GetLength() != 0; } diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp index 7220693813..eaa16c9fe1 100644 --- a/fxjs/cjs_publicmethods.cpp +++ b/fxjs/cjs_publicmethods.cpp @@ -73,8 +73,7 @@ const wchar_t* const kFullMonths[] = {L"January", L"February", L"March", template T StrTrim(const T& str) { T result = str; - result.TrimLeft(' '); - result.TrimRight(' '); + result.Trim(' '); return result; } diff --git a/fxjs/cjx_hostpseudomodel.cpp b/fxjs/cjx_hostpseudomodel.cpp index 090f23f7cd..35ab2f88c9 100644 --- a/fxjs/cjx_hostpseudomodel.cpp +++ b/fxjs/cjx_hostpseudomodel.cpp @@ -43,8 +43,7 @@ int32_t FilterName(const WideStringView& wsExpression, pBuf[nCount++] = wCur; } wsFilter.ReleaseBuffer(nCount); - wsFilter.TrimLeft(); - wsFilter.TrimRight(); + wsFilter.Trim(); return nStart; } -- cgit v1.2.3