From a2188df09255b49ad41a89ae9b5de640d0b03126 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Fri, 1 Sep 2017 15:11:12 -0400 Subject: Cleanup usages of Mid(foo, 1), Right(1), and Left(1) Mid(foo, 1) is equivalent to [foo], if all you want is the character. Similarly Left(1) is [0]. It is faster also, since it does not need to create intermediate strings. Right(1) is a touch more tricky, since it requires something like GetLength() ? [GetLength() - 1] : 0;. A new method, Last() has been added to perform this character extraction. Multiple call sites have been updated to use more efficient/simpler syntax. There are a number of call sites that use on these patterns, but based on the surrounding context we actually need/want a string, so they have not been modified. Change-Id: I485a7f9c7b34c9bdacecada610158f996816afdd Reviewed-on: https://pdfium-review.googlesource.com/12890 Commit-Queue: Ryan Harrison Reviewed-by: Tom Sepez --- xfa/fxfa/parser/cxfa_resolveprocessor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'xfa/fxfa/parser/cxfa_resolveprocessor.cpp') diff --git a/xfa/fxfa/parser/cxfa_resolveprocessor.cpp b/xfa/fxfa/parser/cxfa_resolveprocessor.cpp index fe4605b4f0..15c3f14b23 100644 --- a/xfa/fxfa/parser/cxfa_resolveprocessor.cpp +++ b/xfa/fxfa/parser/cxfa_resolveprocessor.cpp @@ -661,9 +661,9 @@ void CXFA_ResolveProcessor::DoPredicateFilter(int32_t iCurIndex, ASSERT(iFoundCount == pdfium::CollectionSize(rnd.m_Objects)); CFX_WideString wsExpression; XFA_SCRIPTLANGTYPE eLangType = XFA_SCRIPTLANGTYPE_Unkown; - if (wsCondition.Left(2) == L".[" && wsCondition.Right(1) == L"]") { + if (wsCondition.Left(2) == L".[" && wsCondition.Last() == L']') { eLangType = XFA_SCRIPTLANGTYPE_Formcalc; - } else if (wsCondition.Left(2) == L".(" && wsCondition.Right(1) == L")") { + } else if (wsCondition.Left(2) == L".(" && wsCondition.Last() == L')') { eLangType = XFA_SCRIPTLANGTYPE_Javascript; } else { return; -- cgit v1.2.3