aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2020-10-27 15:51:41 +0100
committerJay Berkenbilt <ejb@ql.org>2020-10-27 16:57:48 +0100
commitbcea54fcaa16a7d5feff0c4cd038fea51d1359ea (patch)
tree2c0dc1076a7963c0d9ac77fc8bb87a57ef7ad964 /libqpdf
parent81d2c548dc619e21519651606970c21f720c8658 (diff)
downloadqpdf-bcea54fcaa16a7d5feff0c4cd038fea51d1359ea.tar.zst
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.
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/FileInputSource.cc2
-rw-r--r--libqpdf/QPDF.cc6
-rw-r--r--libqpdf/QPDFTokenizer.cc2
3 files changed, 5 insertions, 5 deletions
diff --git a/libqpdf/FileInputSource.cc b/libqpdf/FileInputSource.cc
index 5ec6a170..cd8feda4 100644
--- a/libqpdf/FileInputSource.cc
+++ b/libqpdf/FileInputSource.cc
@@ -80,7 +80,7 @@ FileInputSource::findAndSkipNextEOL()
}
else if (! ((ch == '\r') || (ch == '\n')))
{
- this->seek(-1, SEEK_CUR);
+ this->unreadCh(ch);
done = true;
}
}
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<InputSource> 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<InputSource> 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(),
diff --git a/libqpdf/QPDFTokenizer.cc b/libqpdf/QPDFTokenizer.cc
index 4f2e2153..4217575c 100644
--- a/libqpdf/QPDFTokenizer.cc
+++ b/libqpdf/QPDFTokenizer.cc
@@ -855,7 +855,7 @@ QPDFTokenizer::readToken(PointerHolder<InputSource> input,
if (unread_char)
{
- input->seek(-1, SEEK_CUR);
+ input->unreadCh(char_to_unread);
}
if (token.getType() != tt_eof)