Chromium Code Reviews| Index: core/fpdfdoc/cpdf_formfield.cpp |
| diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp |
| index cc7054dfaf7365ea0bf8442dbf146c89cf980e51..8d57a2905fe95d8a4ac9d8b196b5896116b45b05 100644 |
| --- a/core/fpdfdoc/cpdf_formfield.cpp |
| +++ b/core/fpdfdoc/cpdf_formfield.cpp |
| @@ -245,11 +245,8 @@ int CPDF_FormField::GetControlIndex(const CPDF_FormControl* pControl) const { |
| if (!pControl) |
| return -1; |
| - for (int i = 0; i < m_ControlList.GetSize(); i++) { |
| - if (m_ControlList.GetAt(i) == pControl) |
| - return i; |
| - } |
| - return -1; |
| + auto it = std::find(m_ControlList.begin(), m_ControlList.end(), pControl); |
| + return it != m_ControlList.end() ? it - m_ControlList.begin() : -1; |
|
dsinclair
2017/01/10 14:11:10
What are your thoughts on std::tie? It would be ni
Tom Sepez
2017/01/10 18:06:27
I really like this approach where there ain't no o
|
| } |
| int CPDF_FormField::GetFieldType() const { |
| @@ -414,11 +411,9 @@ int CPDF_FormField::GetMaxLen() const { |
| if (CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "MaxLen")) |
| return pObj->GetInteger(); |
| - for (int i = 0; i < m_ControlList.GetSize(); i++) { |
| - CPDF_FormControl* pControl = m_ControlList.GetAt(i); |
| + for (const CPDF_FormControl* pControl : m_ControlList) { |
|
dsinclair
2017/01/10 14:11:11
auto?
Tom Sepez
2017/01/10 18:06:27
Done.
|
| if (!pControl) |
| continue; |
| - |
| CPDF_Dictionary* pWidgetDict = pControl->m_pWidgetDict; |
| if (pWidgetDict->KeyExist("MaxLen")) |
| return pWidgetDict->GetIntegerFor("MaxLen"); |