summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/parser')
-rw-r--r--core/fpdfapi/parser/cpdf_array.cpp13
-rw-r--r--core/fpdfapi/parser/cpdf_array.h3
-rw-r--r--core/fpdfapi/parser/cpdf_array_unittest.cpp26
3 files changed, 4 insertions, 38 deletions
diff --git a/core/fpdfapi/parser/cpdf_array.cpp b/core/fpdfapi/parser/cpdf_array.cpp
index 1f2740ea9c..5d079a38b4 100644
--- a/core/fpdfapi/parser/cpdf_array.cpp
+++ b/core/fpdfapi/parser/cpdf_array.cpp
@@ -142,20 +142,13 @@ CPDF_Array* CPDF_Array::GetArrayAt(size_t i) const {
return ToArray(GetDirectObjectAt(i));
}
-void CPDF_Array::RemoveAt(size_t i) {
- if (i < m_Objects.size())
- m_Objects.erase(m_Objects.begin() + i);
-}
-
void CPDF_Array::Clear() {
m_Objects.clear();
}
-void CPDF_Array::Truncate(size_t nNewSize) {
- if (nNewSize >= m_Objects.size())
- return;
-
- m_Objects.resize(nNewSize);
+void CPDF_Array::RemoveAt(size_t i) {
+ if (i < m_Objects.size())
+ m_Objects.erase(m_Objects.begin() + i);
}
void CPDF_Array::ConvertToIndirectObjectAt(size_t i,
diff --git a/core/fpdfapi/parser/cpdf_array.h b/core/fpdfapi/parser/cpdf_array.h
index 2590971d80..ed5d3e33fd 100644
--- a/core/fpdfapi/parser/cpdf_array.h
+++ b/core/fpdfapi/parser/cpdf_array.h
@@ -100,9 +100,8 @@ class CPDF_Array : public CPDF_Object {
index, pdfium::MakeUnique<T>(m_pPool, std::forward<Args>(args)...)));
}
- void RemoveAt(size_t index);
void Clear();
- void Truncate(size_t nNewSize);
+ void RemoveAt(size_t index);
void ConvertToIndirectObjectAt(size_t index, CPDF_IndirectObjectHolder* pDoc);
const_iterator begin() const { return m_Objects.begin(); }
diff --git a/core/fpdfapi/parser/cpdf_array_unittest.cpp b/core/fpdfapi/parser/cpdf_array_unittest.cpp
index 006e5fad33..4ce66dcadb 100644
--- a/core/fpdfapi/parser/cpdf_array_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_array_unittest.cpp
@@ -53,32 +53,6 @@ TEST(cpdf_array, Clear) {
EXPECT_EQ(0U, arr->GetCount());
}
-TEST(cpdf_array, Truncate) {
- {
- const int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
- auto arr = pdfium::MakeUnique<CPDF_Array>();
- for (size_t i = 0; i < FX_ArraySize(elems); ++i)
- arr->AddNew<CPDF_Number>(elems[i]);
- arr->Truncate(4);
- const int expected[] = {1, 2, 3, 4};
- ASSERT_EQ(FX_ArraySize(expected), arr->GetCount());
- for (size_t i = 0; i < FX_ArraySize(expected); ++i)
- EXPECT_EQ(expected[i], arr->GetIntegerAt(i));
- arr->Truncate(0);
- EXPECT_EQ(0U, arr->GetCount());
- }
- {
- // When the range is out of bound, Truncate() has no effect.
- // It does not try to grow the array.
- const int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
- auto arr = pdfium::MakeUnique<CPDF_Array>();
- for (size_t i = 0; i < FX_ArraySize(elems); ++i)
- arr->AddNew<CPDF_Number>(elems[i]);
- arr->Truncate(11);
- EXPECT_EQ(FX_ArraySize(elems), arr->GetCount());
- }
-}
-
TEST(cpdf_array, InsertAt) {
{
const int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};