summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_node.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/parser/cxfa_node.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/parser/cxfa_node.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 1265988902..261fee1971 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -77,7 +77,7 @@ int32_t GetCount(CXFA_Node* pInstMgrNode) {
CFX_WideStringC wsName = pNode->GetCData(XFA_ATTRIBUTE_Name);
CFX_WideStringC wsInstName = pInstMgrNode->GetCData(XFA_ATTRIBUTE_Name);
if (wsInstName.GetLength() < 1 || wsInstName.GetAt(0) != '_' ||
- wsInstName.Mid(1, wsInstName.GetLength() - 1) != wsName) {
+ wsInstName.Right(wsInstName.GetLength() - 1) != wsName) {
return iCount;
}
dwNameHash = pNode->GetNameHash();
@@ -198,7 +198,7 @@ CXFA_Node* GetItem(CXFA_Node* pInstMgrNode, int32_t iIndex) {
CFX_WideStringC wsName = pNode->GetCData(XFA_ATTRIBUTE_Name);
CFX_WideStringC wsInstName = pInstMgrNode->GetCData(XFA_ATTRIBUTE_Name);
if (wsInstName.GetLength() < 1 || wsInstName.GetAt(0) != '_' ||
- wsInstName.Mid(1, wsInstName.GetLength() - 1) != wsName) {
+ wsInstName.Right(wsInstName.GetLength() - 1) != wsName) {
return nullptr;
}
dwNameHash = pNode->GetNameHash();
@@ -2737,7 +2737,7 @@ void CXFA_Node::Script_Subform_InstanceManager(CFXJSE_Value* pValue,
if (pNode->GetElementType() == XFA_Element::InstanceManager) {
CFX_WideStringC wsInstMgrName = pNode->GetCData(XFA_ATTRIBUTE_Name);
if (wsInstMgrName.GetLength() >= 1 && wsInstMgrName.GetAt(0) == '_' &&
- wsInstMgrName.Mid(1, wsInstMgrName.GetLength() - 1) == wsName) {
+ wsInstMgrName.Right(wsInstMgrName.GetLength() - 1) == wsName) {
pInstanceMgr = pNode;
}
break;
@@ -3165,7 +3165,7 @@ int32_t CXFA_Node::InstanceManager_SetInstances(int32_t iDesired) {
CFX_WideString wsInstanceName = CFX_WideString(
wsInstManagerName.IsEmpty()
? wsInstManagerName
- : wsInstManagerName.Mid(1, wsInstManagerName.GetLength() - 1));
+ : wsInstManagerName.Right(wsInstManagerName.GetLength() - 1));
uint32_t dInstanceNameHash =
FX_HashCode_GetW(wsInstanceName.AsStringC(), false);
CXFA_Node* pPrevSibling =
@@ -4665,7 +4665,7 @@ CXFA_Node* CXFA_Node::GetInstanceMgrOfSubform() {
CFX_WideStringC wsName = GetCData(XFA_ATTRIBUTE_Name);
CFX_WideStringC wsInstName = pNode->GetCData(XFA_ATTRIBUTE_Name);
if (wsInstName.GetLength() > 0 && wsInstName.GetAt(0) == '_' &&
- wsInstName.Mid(1, wsInstName.GetLength() - 1) == wsName) {
+ wsInstName.Right(wsInstName.GetLength() - 1) == wsName) {
pInstanceMgr = pNode;
}
break;