From bcea54fcaa16a7d5feff0c4cd038fea51d1359ea Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Tue, 27 Oct 2020 10:51:41 -0400 Subject: Revert removal of unreadCh change for performance Turns out unreadCh is much more efficient than seek(-1, SEEK_CUR). Update comments and code to reflect this. --- libqpdf/QPDF.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libqpdf/QPDF.cc') diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index d256e444..d4d7d519 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -632,7 +632,7 @@ QPDF::read_xref(qpdf_offset_t xref_offset) } else { - this->m->file->seek(-1, SEEK_CUR); + this->m->file->unreadCh(ch); done = true; } } @@ -1604,7 +1604,7 @@ QPDF::readObject(PointerHolder input, // start reading stream data in spite // of not having seen a newline. QTC::TC("qpdf", "QPDF stream with CR only"); - input->seek(-1, SEEK_CUR); + input->unreadCh(ch); warn(QPDFExc( qpdf_e_damaged_pdf, input->getName(), @@ -1629,7 +1629,7 @@ QPDF::readObject(PointerHolder input, else { QTC::TC("qpdf", "QPDF stream without newline"); - input->seek(-1, SEEK_CUR); + input->unreadCh(ch); warn(QPDFExc(qpdf_e_damaged_pdf, input->getName(), this->m->last_object_description, input->tell(), -- cgit v1.2.3-70-g09d2