Index: core/src/fpdfdoc/doc_action.cpp |
diff --git a/core/src/fpdfdoc/doc_action.cpp b/core/src/fpdfdoc/doc_action.cpp |
index d685f64caee28fb6ea311309fdd8331753832a9c..cece6f4cd2b22e646272a259ee98ed5402a8e10f 100644 |
--- a/core/src/fpdfdoc/doc_action.cpp |
+++ b/core/src/fpdfdoc/doc_action.cpp |
@@ -111,37 +111,39 @@ FX_DWORD CPDF_ActionFields::GetFieldsCount() const { |
return pArray->GetCount(); |
return 0; |
} |
-void CPDF_ActionFields::GetAllFields(CFX_PtrArray& fieldObjects) const { |
- fieldObjects.RemoveAll(); |
- if (m_pAction == NULL) { |
- return; |
- } |
+ |
+std::vector<CPDF_Object*> CPDF_ActionFields::GetAllFields() const { |
Tom Sepez
2015/11/09 21:25:31
Is this always small, or are we just counting on c
Lei Zhang
2015/11/09 22:45:28
We do this in Chromium's base/ too. It's RVO.
|
+ std::vector<CPDF_Object*> fields; |
+ if (!m_pAction) |
+ return fields; |
+ |
CPDF_Dictionary* pDict = m_pAction->GetDict(); |
- if (pDict == NULL) { |
- return; |
- } |
+ if (!pDict) |
+ return fields; |
+ |
CFX_ByteString csType = pDict->GetString("S"); |
- CPDF_Object* pFields = NULL; |
- if (csType == "Hide") { |
+ CPDF_Object* pFields; |
+ if (csType == "Hide") |
pFields = pDict->GetElementValue("T"); |
- } else { |
+ else |
pFields = pDict->GetArray("Fields"); |
- } |
if (!pFields) |
- return; |
+ return fields; |
if (pFields->IsDictionary() || pFields->IsString()) { |
- fieldObjects.Add(pFields); |
+ fields.push_back(pFields); |
} else if (CPDF_Array* pArray = pFields->AsArray()) { |
FX_DWORD iCount = pArray->GetCount(); |
- for (FX_DWORD i = 0; i < iCount; i++) { |
+ for (FX_DWORD i = 0; i < iCount; ++i) { |
CPDF_Object* pObj = pArray->GetElementValue(i); |
- if (pObj != NULL) { |
- fieldObjects.Add(pObj); |
+ if (pObj) { |
+ fields.push_back(pObj); |
} |
} |
} |
+ return fields; |
} |
+ |
CPDF_Object* CPDF_ActionFields::GetField(FX_DWORD iIndex) const { |
if (m_pAction == NULL) { |
return NULL; |