summaryrefslogtreecommitdiff
path: root/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-07-28 14:07:04 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-07-28 18:21:44 +0000
commite7a99de4f711302d57fe22682a9a8c3cfddb458c (patch)
tree7bb176d42e2a2181f014b41bd621d6b242ed20e7 /xfa/fxfa/fm2js/cxfa_fmexpression.cpp
parent106eecd27f346a0bc7f11f29a058a8fd16a77682 (diff)
downloadpdfium-e7a99de4f711302d57fe22682a9a8c3cfddb458c.tar.xz
Convert calls to Mid() to Left() or Right() if possible
The various string/byte classes support Mid(), Left(), and Right() for extracting substrings. Mid() can handle all possible cases, but Left() and Right() are useful for common cases and more explicit about what is going on. Calls like Mid(offset, length - offset) can be converted to Right(length - offset). Calls like Mid(0, length) can be converted to Left(length). If the substring being extracted does not extend all the way to one of the edges of the string, then Mid() still needs to be used. BUG=pdfium:828 Change-Id: I2ec46ad3d71aac0f7b513e103c69cbe8c854cf62 Reviewed-on: https://pdfium-review.googlesource.com/9510 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fxfa/fm2js/cxfa_fmexpression.cpp')
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmexpression.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fmexpression.cpp b/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
index b201863b25..a74239ff82 100644
--- a/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
@@ -62,7 +62,7 @@ bool CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << L"function ";
if (m_wsName.GetAt(0) == L'!') {
CFX_WideString tempName =
- EXCLAMATION_IN_IDENTIFIER + m_wsName.Mid(1, m_wsName.GetLength() - 1);
+ EXCLAMATION_IN_IDENTIFIER + m_wsName.Right(m_wsName.GetLength() - 1);
javascript << tempName;
} else {
javascript << m_wsName;
@@ -75,7 +75,7 @@ bool CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) {
if (identifier.GetAt(0) == L'!') {
CFX_WideString tempIdentifier =
EXCLAMATION_IN_IDENTIFIER +
- identifier.Mid(1, identifier.GetLength() - 1);
+ identifier.Right(identifier.GetLength() - 1);
javascript << tempIdentifier;
} else {
javascript << identifier;
@@ -130,7 +130,7 @@ bool CXFA_FMVarExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CFX_WideString tempName(m_wsName);
if (m_wsName.GetAt(0) == L'!') {
tempName =
- EXCLAMATION_IN_IDENTIFIER + m_wsName.Mid(1, m_wsName.GetLength() - 1);
+ EXCLAMATION_IN_IDENTIFIER + m_wsName.Right(m_wsName.GetLength() - 1);
}
javascript << tempName;
javascript << L" = ";
@@ -154,7 +154,7 @@ bool CXFA_FMVarExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
CFX_WideString tempName(m_wsName);
if (m_wsName.GetAt(0) == L'!') {
tempName =
- EXCLAMATION_IN_IDENTIFIER + m_wsName.Mid(1, m_wsName.GetLength() - 1);
+ EXCLAMATION_IN_IDENTIFIER + m_wsName.Right(m_wsName.GetLength() - 1);
}
javascript << tempName;
javascript << L" = ";
@@ -461,7 +461,7 @@ bool CXFA_FMForExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CFX_WideString tempVariant;
if (m_wsVariant.GetAt(0) == L'!') {
tempVariant = EXCLAMATION_IN_IDENTIFIER +
- m_wsVariant.Mid(1, m_wsVariant.GetLength() - 1);
+ m_wsVariant.Right(m_wsVariant.GetLength() - 1);
javascript << tempVariant;
} else {
tempVariant = m_wsVariant;
@@ -516,7 +516,7 @@ bool CXFA_FMForExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
CFX_WideString tempVariant;
if (m_wsVariant.GetAt(0) == L'!') {
tempVariant = EXCLAMATION_IN_IDENTIFIER +
- m_wsVariant.Mid(1, m_wsVariant.GetLength() - 1);
+ m_wsVariant.Right(m_wsVariant.GetLength() - 1);
javascript << tempVariant;
} else {
tempVariant = m_wsVariant;
@@ -583,7 +583,7 @@ bool CXFA_FMForeachExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
if (m_wsIdentifier.GetAt(0) == L'!') {
CFX_WideString tempIdentifier =
EXCLAMATION_IN_IDENTIFIER +
- m_wsIdentifier.Mid(1, m_wsIdentifier.GetLength() - 1);
+ m_wsIdentifier.Right(m_wsIdentifier.GetLength() - 1);
javascript << tempIdentifier;
} else {
javascript << m_wsIdentifier;
@@ -615,7 +615,7 @@ bool CXFA_FMForeachExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
if (m_wsIdentifier.GetAt(0) == L'!') {
CFX_WideString tempIdentifier =
EXCLAMATION_IN_IDENTIFIER +
- m_wsIdentifier.Mid(1, m_wsIdentifier.GetLength() - 1);
+ m_wsIdentifier.Right(m_wsIdentifier.GetLength() - 1);
javascript << tempIdentifier;
} else {
javascript << m_wsIdentifier;
@@ -640,7 +640,7 @@ bool CXFA_FMForeachExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
if (m_wsIdentifier.GetAt(0) == L'!') {
CFX_WideString tempIdentifier =
EXCLAMATION_IN_IDENTIFIER +
- m_wsIdentifier.Mid(1, m_wsIdentifier.GetLength() - 1);
+ m_wsIdentifier.Right(m_wsIdentifier.GetLength() - 1);
javascript << tempIdentifier;
} else {
javascript << m_wsIdentifier;
@@ -671,7 +671,7 @@ bool CXFA_FMForeachExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
if (m_wsIdentifier.GetAt(0) == L'!') {
CFX_WideString tempIdentifier =
EXCLAMATION_IN_IDENTIFIER +
- m_wsIdentifier.Mid(1, m_wsIdentifier.GetLength() - 1);
+ m_wsIdentifier.Right(m_wsIdentifier.GetLength() - 1);
javascript << tempIdentifier;
} else {
javascript << m_wsIdentifier;