aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF_Array.cc
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2022-12-12 14:29:52 +0100
committerm-holger <m-holger@kubitscheck.org>2023-04-01 14:56:16 +0200
commit4d37389befc705b671d8fa7a1da2b7117b50f454 (patch)
tree0fd25b3c7d60a75d5873b430fe801ac26e0f4a58 /libqpdf/QPDF_Array.cc
parent1bb23d0545dfe2d651cb22b6135d99c1c9ef85d5 (diff)
downloadqpdf-4d37389befc705b671d8fa7a1da2b7117b50f454.tar.zst
Refactor QPDF_Array::eraseItem and rename to erase
Diffstat (limited to 'libqpdf/QPDF_Array.cc')
-rw-r--r--libqpdf/QPDF_Array.cc15
1 files changed, 7 insertions, 8 deletions
diff --git a/libqpdf/QPDF_Array.cc b/libqpdf/QPDF_Array.cc
index 7633266e..e4e1668e 100644
--- a/libqpdf/QPDF_Array.cc
+++ b/libqpdf/QPDF_Array.cc
@@ -267,17 +267,16 @@ QPDF_Array::push_back(QPDFObjectHandle const& item)
}
}
-void
-QPDF_Array::eraseItem(int at)
+bool
+QPDF_Array::erase(int at)
{
+ if (at < 0 || at >= size()) {
+ return false;
+ }
if (sparse) {
sp_elements.erase(at);
} else {
- size_t idx = QIntC::to_size(at);
- if (idx >= elements.size()) {
- throw std::logic_error("bounds error erasing item from OHArray");
- }
- int n = int(idx);
- elements.erase(elements.cbegin() + n);
+ elements.erase(elements.cbegin() + at);
}
+ return true;
}