From 727da4f329956406b936ba9c0bc49ab2d32db67e Mon Sep 17 00:00:00 2001 From: jaepark Date: Mon, 8 Aug 2016 15:45:58 -0700 Subject: Add CPDF_Array::IsEmpty(). Using IsEmpty() is more readable than using GetCount() == 0. Review-Url: https://codereview.chromium.org/2226113002 --- core/fpdfapi/fpdf_page/cpdf_colorspace.cpp | 2 +- core/fpdfapi/fpdf_page/fpdf_page_doc.cpp | 2 +- core/fpdfapi/fpdf_parser/include/cpdf_array.h | 1 + core/fpdfdoc/cpdf_formfield.cpp | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) (limited to 'core') diff --git a/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp b/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp index 9d3aeb2adc..759d0f37b5 100644 --- a/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp @@ -355,7 +355,7 @@ CPDF_ColorSpace* CPDF_ColorSpace::Load(CPDF_Document* pDoc, CPDF_Object* pObj) { } CPDF_Array* pArray = pObj->AsArray(); - if (!pArray || pArray->GetCount() == 0) + if (!pArray || pArray->IsEmpty()) return nullptr; CPDF_Object* pFamilyObj = pArray->GetDirectObjectAt(0); diff --git a/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp b/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp index 059679a8cd..f8d7575318 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp @@ -275,7 +275,7 @@ CPDF_ColorSpace* CPDF_DocPageData::GetColorSpaceImpl( } CPDF_Array* pArray = pCSObj->AsArray(); - if (!pArray || pArray->GetCount() == 0) + if (!pArray || pArray->IsEmpty()) return nullptr; if (pArray->GetCount() == 1) { diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_array.h b/core/fpdfapi/fpdf_parser/include/cpdf_array.h index 0629046d9e..9bb99da053 100644 --- a/core/fpdfapi/fpdf_parser/include/cpdf_array.h +++ b/core/fpdfapi/fpdf_parser/include/cpdf_array.h @@ -28,6 +28,7 @@ class CPDF_Array : public CPDF_Object { CPDF_Array* AsArray() override; const CPDF_Array* AsArray() const override; + bool IsEmpty() const { return m_Objects.empty(); } size_t GetCount() const { return m_Objects.size(); } CPDF_Object* GetObjectAt(size_t index) const; CPDF_Object* GetDirectObjectAt(size_t index) const; diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp index 81d2178820..ac6c01bae2 100644 --- a/core/fpdfdoc/cpdf_formfield.cpp +++ b/core/fpdfdoc/cpdf_formfield.cpp @@ -887,7 +887,7 @@ FX_BOOL CPDF_FormField::SelectOption(int iOptIndex, if (bSelected) pArray->AddInteger(iOptIndex); - if (pArray->GetCount() == 0) + if (pArray->IsEmpty()) m_pDict->RemoveAt("I"); } if (bNotify) -- cgit v1.2.3