Simplify CFXJSE_FormCalcContext::unfoldArgs().

Return results instead of writing them to an out parameter. Remove start
index which is always 1.

Change-Id: I4b969a1e27679fca56b2cde1a901a8967c7fa8ce
Reviewed-on: https://pdfium-review.googlesource.com/39092
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
diff --git a/fxjs/cfxjse_formcalc_context.cpp b/fxjs/cfxjse_formcalc_context.cpp
index 94f3256..55233c1 100644
--- a/fxjs/cfxjse_formcalc_context.cpp
+++ b/fxjs/cfxjse_formcalc_context.cpp
@@ -3336,8 +3336,8 @@
 
   bool bFlags = false;
   std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
-  std::vector<std::unique_ptr<CFXJSE_Value>> parameterValues;
-  unfoldArgs(pThis, args, &parameterValues, 1);
+  std::vector<std::unique_ptr<CFXJSE_Value>> parameterValues =
+      unfoldArgs(pThis, args);
   for (const auto& value : parameterValues) {
     if (simpleValueCompare(pThis, argOne.get(), value.get())) {
       bFlags = true;
@@ -5764,19 +5764,18 @@
 }
 
 // static
-void CFXJSE_FormCalcContext::unfoldArgs(
+std::vector<std::unique_ptr<CFXJSE_Value>> CFXJSE_FormCalcContext::unfoldArgs(
     CFXJSE_Value* pThis,
-    CFXJSE_Arguments& args,
-    std::vector<std::unique_ptr<CFXJSE_Value>>* resultValues,
-    int32_t iStart) {
-  resultValues->clear();
+    CFXJSE_Arguments& args) {
+  std::vector<std::unique_ptr<CFXJSE_Value>> results;
 
   int32_t iCount = 0;
   v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetScriptRuntime();
   int32_t argc = args.GetLength();
   std::vector<std::unique_ptr<CFXJSE_Value>> argsValue;
-  for (int32_t i = 0; i < argc - iStart; i++) {
-    argsValue.push_back(args.GetValue(i + iStart));
+  static constexpr int kStart = 1;
+  for (int32_t i = 0; i < argc - kStart; i++) {
+    argsValue.push_back(args.GetValue(i + kStart));
     if (argsValue[i]->IsArray()) {
       auto lengthValue = pdfium::MakeUnique<CFXJSE_Value>(pIsolate);
       argsValue[i]->GetObjectProperty("length", lengthValue.get());
@@ -5788,10 +5787,10 @@
   }
 
   for (int32_t i = 0; i < iCount; i++)
-    resultValues->push_back(pdfium::MakeUnique<CFXJSE_Value>(pIsolate));
+    results.push_back(pdfium::MakeUnique<CFXJSE_Value>(pIsolate));
 
   int32_t index = 0;
-  for (int32_t i = 0; i < argc - iStart; i++) {
+  for (int32_t i = 0; i < argc - kStart; i++) {
     if (argsValue[i]->IsArray()) {
       auto lengthValue = pdfium::MakeUnique<CFXJSE_Value>(pIsolate);
       argsValue[i]->GetObjectProperty("length", lengthValue.get());
@@ -5805,27 +5804,26 @@
       if (propertyValue->IsNull()) {
         for (int32_t j = 2; j < iLength; j++) {
           argsValue[i]->GetObjectPropertyByIdx(j, jsObjectValue.get());
-          GetObjectDefaultValue(jsObjectValue.get(),
-                                (*resultValues)[index].get());
+          GetObjectDefaultValue(jsObjectValue.get(), results[index].get());
           index++;
         }
       } else {
         for (int32_t j = 2; j < iLength; j++) {
           argsValue[i]->GetObjectPropertyByIdx(j, jsObjectValue.get());
           jsObjectValue->GetObjectProperty(
-              propertyValue->ToString().AsStringView(),
-              (*resultValues)[index].get());
+              propertyValue->ToString().AsStringView(), results[index].get());
           index++;
         }
       }
     } else if (argsValue[i]->IsObject()) {
-      GetObjectDefaultValue(argsValue[i].get(), (*resultValues)[index].get());
+      GetObjectDefaultValue(argsValue[i].get(), results[index].get());
       index++;
     } else {
-      (*resultValues)[index]->Assign(argsValue[i].get());
+      results[index]->Assign(argsValue[i].get());
       index++;
     }
   }
+  return results;
 }
 
 // static
diff --git a/fxjs/cfxjse_formcalc_context.h b/fxjs/cfxjse_formcalc_context.h
index f605603..e95cc5f 100644
--- a/fxjs/cfxjse_formcalc_context.h
+++ b/fxjs/cfxjse_formcalc_context.h
@@ -343,11 +343,9 @@
   static bool simpleValueCompare(CFXJSE_Value* pThis,
                                  CFXJSE_Value* firstValue,
                                  CFXJSE_Value* secondValue);
-  static void unfoldArgs(
+  static std::vector<std::unique_ptr<CFXJSE_Value>> unfoldArgs(
       CFXJSE_Value* pThis,
-      CFXJSE_Arguments& args,
-      std::vector<std::unique_ptr<CFXJSE_Value>>* resultValues,
-      int32_t iStart = 0);
+      CFXJSE_Arguments& args);
   static void GetObjectDefaultValue(CFXJSE_Value* pObjectValue,
                                     CFXJSE_Value* pDefaultValue);
   static bool SetObjectDefaultValue(CFXJSE_Value* pObjectValue,