summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_page
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-03-03 10:12:47 -0800
committerTom Sepez <tsepez@chromium.org>2016-03-03 10:12:47 -0800
commitf3e3af606958855c9345dd3aba13e75f0b879193 (patch)
tree8cb3cbd40a355d906d9be9641c747b5721796de1 /core/src/fpdfapi/fpdf_page
parentda17d6cd9a4abc6ff41e18faa2757f98caf797db (diff)
downloadpdfium-f3e3af606958855c9345dd3aba13e75f0b879193.tar.xz
Fix O(n^2) behaviour in parser.
Despite what the c++11 spec says, std::list::size() is still O(n), not O(1). R=dsinclair@chromium.org, ochang@chromium.org Review URL: https://codereview.chromium.org/1763443003 .
Diffstat (limited to 'core/src/fpdfapi/fpdf_page')
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page.cpp8
1 files changed, 1 insertions, 7 deletions
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()