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>
diff --git a/fxjs/cfxjse_engine.cpp b/fxjs/cfxjse_engine.cpp
index 1812d02..305e29a 100644
--- a/fxjs/cfxjse_engine.cpp
+++ b/fxjs/cfxjse_engine.cpp
@@ -585,11 +585,12 @@
   }
 
   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 @@
     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 @@
         }
         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 @@
     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 @@
   }
   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 bf561e7..2279eea 100644
--- a/fxjs/cfxjse_engine.h
+++ b/fxjs/cfxjse_engine.h
@@ -118,7 +118,7 @@
   // 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 521128b..dea7abd 100644
--- a/fxjs/cfxjse_resolveprocessor.h
+++ b/fxjs/cfxjse_resolveprocessor.h
@@ -46,7 +46,7 @@
                         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,