Commit 1c85e7ece4d832b114f91c1858ba2b24964d5d9e
1 parent
6295da43
Remove SparseOHArray::erase
Showing
3 changed files
with
14 additions
and
21 deletions
libqpdf/QPDF_Array.cc
| @@ -284,7 +284,20 @@ QPDF_Array::erase(int at) | @@ -284,7 +284,20 @@ QPDF_Array::erase(int at) | ||
| 284 | return false; | 284 | return false; |
| 285 | } | 285 | } |
| 286 | if (sparse) { | 286 | if (sparse) { |
| 287 | - sp_elements.erase(at); | 287 | + auto end = sp_elements.elements.end(); |
| 288 | + if (auto iter = sp_elements.elements.lower_bound(at); iter != end) { | ||
| 289 | + if (iter->first == at) { | ||
| 290 | + iter++; | ||
| 291 | + sp_elements.elements.erase(at); | ||
| 292 | + } | ||
| 293 | + | ||
| 294 | + while (iter != end) { | ||
| 295 | + auto nh = sp_elements.elements.extract(iter++); | ||
| 296 | + --nh.key(); | ||
| 297 | + sp_elements.elements.insert(std::move(nh)); | ||
| 298 | + } | ||
| 299 | + } | ||
| 300 | + --sp_elements.n_elements; | ||
| 288 | } else { | 301 | } else { |
| 289 | elements.erase(elements.cbegin() + at); | 302 | elements.erase(elements.cbegin() + at); |
| 290 | } | 303 | } |
libqpdf/SparseOHArray.cc
| @@ -30,25 +30,6 @@ SparseOHArray::disconnect() | @@ -30,25 +30,6 @@ SparseOHArray::disconnect() | ||
| 30 | } | 30 | } |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | -void | ||
| 34 | -SparseOHArray::erase(int at) | ||
| 35 | -{ | ||
| 36 | - auto end = elements.end(); | ||
| 37 | - if (auto iter = elements.lower_bound(at); iter != end) { | ||
| 38 | - if (iter->first == at) { | ||
| 39 | - iter++; | ||
| 40 | - elements.erase(at); | ||
| 41 | - } | ||
| 42 | - | ||
| 43 | - while (iter != end) { | ||
| 44 | - auto nh = elements.extract(iter++); | ||
| 45 | - --nh.key(); | ||
| 46 | - elements.insert(std::move(nh)); | ||
| 47 | - } | ||
| 48 | - } | ||
| 49 | - --n_elements; | ||
| 50 | -} | ||
| 51 | - | ||
| 52 | SparseOHArray | 33 | SparseOHArray |
| 53 | SparseOHArray::copy() | 34 | SparseOHArray::copy() |
| 54 | { | 35 | { |
libqpdf/qpdf/SparseOHArray.hh