Remove CPDF_FormField::FindOptionValue().
It is identical to FindOption(). At some point in the past,
FindOptionValue() took a starting index parameter (which defaulted
to 0 and was never actually specified in any call) while FindOption()
always started from index 0. But that has long since been removed,
so they are now equivalent.
Pass by const-ref while we're at it.
Change-Id: I3547b8c285b3ee4cbb32a6b4faea06e12bb7e9de
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/52532
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp
index 283c9b3..cb1344d 100644
--- a/core/fpdfdoc/cpdf_formfield.cpp
+++ b/core/fpdfdoc/cpdf_formfield.cpp
@@ -396,7 +396,7 @@
: pdfium::form_fields::kV);
m_pForm->GetDocument()->AddOrphan(m_pDict->RemoveFor(key));
m_pDict->SetNewFor<CPDF_String>(key, csValue);
- int iIndex = FindOptionValue(csValue);
+ int iIndex = FindOption(csValue);
if (iIndex < 0) {
if (m_Type == kRichText && !bDefault) {
m_pForm->GetDocument()->AddOrphan(m_pDict->RemoveFor("RV"));
@@ -414,7 +414,7 @@
break;
}
case kListBox: {
- int iIndex = FindOptionValue(value);
+ int iIndex = FindOption(value);
if (iIndex < 0)
return false;
@@ -701,15 +701,7 @@
return GetOptionText(index, 0);
}
-int CPDF_FormField::FindOption(WideString csOptLabel) const {
- for (int i = 0; i < CountOptions(); i++) {
- if (GetOptionValue(i) == csOptLabel)
- return i;
- }
- return -1;
-}
-
-int CPDF_FormField::FindOptionValue(const WideString& csOptValue) const {
+int CPDF_FormField::FindOption(const WideString& csOptValue) const {
for (int i = 0; i < CountOptions(); i++) {
if (GetOptionValue(i) == csOptValue)
return i;
diff --git a/core/fpdfdoc/cpdf_formfield.h b/core/fpdfdoc/cpdf_formfield.h
index e484282..4937a37 100644
--- a/core/fpdfdoc/cpdf_formfield.h
+++ b/core/fpdfdoc/cpdf_formfield.h
@@ -147,9 +147,7 @@
WideString GetOptionLabel(int index) const;
WideString GetOptionValue(int index) const;
-
- int FindOption(WideString csOptLabel) const;
- int FindOptionValue(const WideString& csOptValue) const;
+ int FindOption(const WideString& csOptValue) const;
bool CheckControl(int iControlIndex,
bool bChecked,