summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/include/fpdfapi/fpdf_page.h6
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page.cpp8
2 files changed, 4 insertions, 10 deletions
diff --git a/core/include/fpdfapi/fpdf_page.h b/core/include/fpdfapi/fpdf_page.h
index 4c880525f1..7c27340525 100644
--- a/core/include/fpdfapi/fpdf_page.h
+++ b/core/include/fpdfapi/fpdf_page.h
@@ -7,7 +7,7 @@
#ifndef CORE_INCLUDE_FPDFAPI_FPDF_PAGE_H_
#define CORE_INCLUDE_FPDFAPI_FPDF_PAGE_H_
-#include <list>
+#include <deque>
#include <memory>
#include "core/include/fpdfapi/fpdf_parser.h"
@@ -27,9 +27,9 @@ class CPDF_ImageObject;
#define PDFTRANS_ISOLATED 0x0200
#define PDFTRANS_KNOCKOUT 0x0400
-class CPDF_PageObjectList : public std::list<std::unique_ptr<CPDF_PageObject>> {
+class CPDF_PageObjectList
+ : public std::deque<std::unique_ptr<CPDF_PageObject>> {
public:
- // Linear complexity, to be avoided except as needed by public APIs.
CPDF_PageObject* GetPageObjectByIndex(int index);
};
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
index 301fca8969..77707624d2 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
@@ -462,13 +462,7 @@ void CPDF_FormObject::CalcBoundingBox() {
CPDF_PageObject* CPDF_PageObjectList::GetPageObjectByIndex(int index) {
if (index < 0 || index >= pdfium::CollectionSize<int>(*this))
return nullptr;
- int current = 0;
- for (const auto& pObj : *this) {
- if (index == current)
- return pObj.get();
- ++current;
- }
- return nullptr;
+ return (*this)[index].get();
}
CPDF_PageObjectHolder::CPDF_PageObjectHolder()