summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-08-29 18:16:40 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-29 18:16:40 +0000
commitd2e4698c5daeba74a231574d63a11a858920ea59 (patch)
tree6086877972dcd3afad8f483817d1830acbc04f9c
parentee68cd18a22e120d5f341199be7e82bfda888da8 (diff)
downloadpdfium-d2e4698c5daeba74a231574d63a11a858920ea59.tar.xz
Reduce the number of CFXJSE_ResolveProcessor::GetNodeHelper() calls.
In CFXJSE_Engine::ResolveObjects(), all the calls are to the same object. Just grab a pointer and reuse that. Also make GetNodeHelper() non-const. Change-Id: I92a0bb1577a11d4d067e6d9beed27fcadeb694dc Reviewed-on: https://pdfium-review.googlesource.com/41573 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
-rw-r--r--fxjs/cfxjse_engine.cpp52
-rw-r--r--fxjs/cfxjse_engine.h2
-rw-r--r--fxjs/cfxjse_resolveprocessor.h2
3 files changed, 26 insertions, 30 deletions
diff --git a/fxjs/cfxjse_engine.cpp b/fxjs/cfxjse_engine.cpp
index 1812d02e50..305e29a9cd 100644
--- a/fxjs/cfxjse_engine.cpp
+++ b/fxjs/cfxjse_engine.cpp
@@ -585,11 +585,12 @@ bool CFXJSE_Engine::ResolveObjects(CXFA_Object* refObject,
}
bool bNextCreate = false;
+ CXFA_NodeHelper* pNodeHelper = m_ResolveProcessor->GetNodeHelper();
if (dwStyles & XFA_RESOLVENODE_CreateNode)
- m_ResolveProcessor->GetNodeHelper()->SetCreateNodeType(bindNode);
+ pNodeHelper->SetCreateNodeType(bindNode);
- m_ResolveProcessor->GetNodeHelper()->m_pCreateParent = nullptr;
- m_ResolveProcessor->GetNodeHelper()->m_iCurAllStart = -1;
+ pNodeHelper->m_pCreateParent = nullptr;
+ pNodeHelper->m_iCurAllStart = -1;
CFXJSE_ResolveNodeData rndFind(this);
int32_t nStart = 0;
@@ -607,7 +608,7 @@ bool CFXJSE_Engine::ResolveObjects(CXFA_Object* refObject,
if (nStart < 1) {
if ((dwStyles & XFA_RESOLVENODE_CreateNode) && !bNextCreate) {
CXFA_Node* pDataNode = nullptr;
- nStart = m_ResolveProcessor->GetNodeHelper()->m_iCurAllStart;
+ nStart = pNodeHelper->m_iCurAllStart;
if (nStart != -1) {
pDataNode = m_pDocument->GetNotBindNode(findObjects);
if (pDataNode) {
@@ -623,19 +624,17 @@ bool CFXJSE_Engine::ResolveObjects(CXFA_Object* refObject,
}
dwStyles |= XFA_RESOLVENODE_Bind;
findObjects.clear();
- findObjects.emplace_back(
- m_ResolveProcessor->GetNodeHelper()->m_pAllStartParent.Get());
+ findObjects.emplace_back(pNodeHelper->m_pAllStartParent.Get());
continue;
}
break;
}
if (bNextCreate) {
- bool bCreate =
- m_ResolveProcessor->GetNodeHelper()->ResolveNodes_CreateNode(
- rndFind.m_wsName, rndFind.m_wsCondition,
- nStart ==
- pdfium::base::checked_cast<int32_t>(wsExpression.GetLength()),
- this);
+ bool bCreate = pNodeHelper->ResolveNodes_CreateNode(
+ rndFind.m_wsName, rndFind.m_wsCondition,
+ nStart ==
+ pdfium::base::checked_cast<int32_t>(wsExpression.GetLength()),
+ this);
if (bCreate)
continue;
@@ -683,17 +682,15 @@ bool CFXJSE_Engine::ResolveObjects(CXFA_Object* refObject,
if (nNodes < 1) {
if (dwStyles & XFA_RESOLVENODE_CreateNode) {
bNextCreate = true;
- if (!m_ResolveProcessor->GetNodeHelper()->m_pCreateParent) {
- m_ResolveProcessor->GetNodeHelper()->m_pCreateParent =
- ToNode(rndFind.m_CurObject);
- m_ResolveProcessor->GetNodeHelper()->m_iCreateCount = 1;
+ if (!pNodeHelper->m_pCreateParent) {
+ pNodeHelper->m_pCreateParent = ToNode(rndFind.m_CurObject);
+ pNodeHelper->m_iCreateCount = 1;
}
- bool bCreate =
- m_ResolveProcessor->GetNodeHelper()->ResolveNodes_CreateNode(
- rndFind.m_wsName, rndFind.m_wsCondition,
- nStart == pdfium::base::checked_cast<int32_t>(
- wsExpression.GetLength()),
- this);
+ bool bCreate = pNodeHelper->ResolveNodes_CreateNode(
+ rndFind.m_wsName, rndFind.m_wsCondition,
+ nStart ==
+ pdfium::base::checked_cast<int32_t>(wsExpression.GetLength()),
+ this);
if (bCreate)
continue;
}
@@ -722,15 +719,14 @@ bool CFXJSE_Engine::ResolveObjects(CXFA_Object* refObject,
}
if (dwStyles & (XFA_RESOLVENODE_CreateNode | XFA_RESOLVENODE_Bind |
XFA_RESOLVENODE_BindNew)) {
- CXFA_NodeHelper* helper = m_ResolveProcessor->GetNodeHelper();
- if (helper->m_pCreateParent)
- resolveNodeRS->objects.emplace_back(helper->m_pCreateParent.Get());
+ if (pNodeHelper->m_pCreateParent)
+ resolveNodeRS->objects.emplace_back(pNodeHelper->m_pCreateParent.Get());
else
- helper->CreateNode_ForCondition(rndFind.m_wsCondition);
+ pNodeHelper->CreateNode_ForCondition(rndFind.m_wsCondition);
- resolveNodeRS->dwFlags = helper->m_iCreateFlag;
+ resolveNodeRS->dwFlags = pNodeHelper->m_iCreateFlag;
if (resolveNodeRS->dwFlags == XFA_ResolveNode_RSType_CreateNodeOne) {
- if (helper->m_iCurAllStart != -1)
+ if (pNodeHelper->m_iCurAllStart != -1)
resolveNodeRS->dwFlags = XFA_ResolveNode_RSType_CreateNodeMidAll;
}
diff --git a/fxjs/cfxjse_engine.h b/fxjs/cfxjse_engine.h
index bf561e7732..2279eea8e4 100644
--- a/fxjs/cfxjse_engine.h
+++ b/fxjs/cfxjse_engine.h
@@ -118,7 +118,7 @@ class CFXJSE_Engine final : public CFX_V8 {
// CacheList holds the List items so we can clean them up when we're done.
std::vector<std::unique_ptr<CXFA_List>> m_CacheList;
std::vector<CXFA_Node*>* m_pScriptNodeArray = nullptr;
- std::unique_ptr<CFXJSE_ResolveProcessor> m_ResolveProcessor;
+ const std::unique_ptr<CFXJSE_ResolveProcessor> m_ResolveProcessor;
std::unique_ptr<CFXJSE_FormCalcContext> m_FM2JSContext;
CXFA_Object* m_pThisObject = nullptr;
XFA_AttributeEnum m_eRunAtType = XFA_AttributeEnum::Client;
diff --git a/fxjs/cfxjse_resolveprocessor.h b/fxjs/cfxjse_resolveprocessor.h
index 521128b62c..dea7abdc5b 100644
--- a/fxjs/cfxjse_resolveprocessor.h
+++ b/fxjs/cfxjse_resolveprocessor.h
@@ -46,7 +46,7 @@ class CFXJSE_ResolveProcessor {
int32_t iCount);
void SetCurStart(int32_t start) { m_iCurStart = start; }
- CXFA_NodeHelper* GetNodeHelper() const { return m_pNodeHelper.get(); }
+ CXFA_NodeHelper* GetNodeHelper() { return m_pNodeHelper.get(); }
private:
bool ResolveForAttributeRs(CXFA_Object* curNode,