aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/SparseOHArray.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libqpdf/SparseOHArray.cc')
-rw-r--r--libqpdf/SparseOHArray.cc14
1 files changed, 4 insertions, 10 deletions
diff --git a/libqpdf/SparseOHArray.cc b/libqpdf/SparseOHArray.cc
index 3f6376a6..c82bf145 100644
--- a/libqpdf/SparseOHArray.cc
+++ b/libqpdf/SparseOHArray.cc
@@ -2,6 +2,8 @@
#include <stdexcept>
+static const QPDFObjectHandle null_oh = QPDFObjectHandle::newNull();
+
void
SparseOHArray::append(QPDFObjectHandle oh)
{
@@ -23,16 +25,8 @@ SparseOHArray::append(std::shared_ptr<QPDFObject>&& obj)
QPDFObjectHandle
SparseOHArray::at(int idx) const
{
- if (idx < 0 || idx >= this->n_elements) {
- throw std::logic_error(
- "INTERNAL ERROR: bounds error accessing SparseOHArray element");
- }
- auto const& iter = this->elements.find(idx);
- if (iter == this->elements.end()) {
- return QPDFObjectHandle::newNull();
- } else {
- return (*iter).second;
- }
+ auto const& iter = elements.find(idx);
+ return iter == elements.end() ? null_oh : (*iter).second;
}
void