Reduce the size of the action string array.

Remove the dummy "Unknown" and nullptr entries. Then adjust the array
usage accordingly. Also rename the array from "g_foo" to "kFoo".

Change-Id: I9c9d74dd1cafa877f932fc5b7fe3bd9ab7e8fc7d
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/79297
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Hui Yingst <nigi@chromium.org>
diff --git a/core/fpdfdoc/cpdf_action.cpp b/core/fpdfdoc/cpdf_action.cpp
index 9e21ad5..1f88724 100644
--- a/core/fpdfdoc/cpdf_action.cpp
+++ b/core/fpdfdoc/cpdf_action.cpp
@@ -12,14 +12,15 @@
 #include "core/fpdfapi/parser/cpdf_document.h"
 #include "core/fpdfapi/parser/cpdf_name.h"
 #include "core/fpdfdoc/cpdf_filespec.h"
+#include "third_party/base/stl_util.h"
 
 namespace {
 
-const char* const g_sATypes[] = {
-    "Unknown",     "GoTo",       "GoToR",     "GoToE",      "Launch",
-    "Thread",      "URI",        "Sound",     "Movie",      "Hide",
-    "Named",       "SubmitForm", "ResetForm", "ImportData", "JavaScript",
-    "SetOCGState", "Rendition",  "Trans",     "GoTo3DView", nullptr};
+const char* const kActionTypeStrings[] = {
+    "GoTo",       "GoToR",     "GoToE",      "Launch",     "Thread",
+    "URI",        "Sound",     "Movie",      "Hide",       "Named",
+    "SubmitForm", "ResetForm", "ImportData", "JavaScript", "SetOCGState",
+    "Rendition",  "Trans",     "GoTo3DView"};
 
 }  // namespace
 
@@ -45,9 +46,12 @@
   if (csType.IsEmpty())
     return Type::kUnknown;
 
-  for (int i = 0; g_sATypes[i]; ++i) {
-    if (csType == g_sATypes[i])
-      return static_cast<Type>(i);
+  static_assert(
+      pdfium::size(kActionTypeStrings) == static_cast<size_t>(Type::kLast),
+      "Type mismatch");
+  for (size_t i = 0; i < pdfium::size(kActionTypeStrings); ++i) {
+    if (csType == kActionTypeStrings[i])
+      return static_cast<Type>(i + 1);
   }
   return Type::kUnknown;
 }
diff --git a/core/fpdfdoc/cpdf_action.h b/core/fpdfdoc/cpdf_action.h
index 9646d59..d60b901 100644
--- a/core/fpdfdoc/cpdf_action.h
+++ b/core/fpdfdoc/cpdf_action.h
@@ -39,7 +39,8 @@
     kSetOCGState,
     kRendition,
     kTrans,
-    kGoTo3DView
+    kGoTo3DView,
+    kLast = kGoTo3DView
   };
 
   explicit CPDF_Action(const CPDF_Dictionary* pDict);