mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 02:49:00 +00:00
Refactor Pl_QPDFTokenizer::finish
Remove unnecessary use of shared pointers and avoid unnecessary string creation.
This commit is contained in:
parent
986a253cdd
commit
1536a76071
@ -36,20 +36,17 @@ void
|
||||
Pl_QPDFTokenizer::finish()
|
||||
{
|
||||
m->buf.finish();
|
||||
auto input = std::shared_ptr<InputSource>(
|
||||
// line-break
|
||||
new BufferInputSource("tokenizer data", m->buf.getBuffer(), true));
|
||||
|
||||
auto input = BufferInputSource("tokenizer data", m->buf.getBuffer(), true);
|
||||
std::string empty;
|
||||
while (true) {
|
||||
QPDFTokenizer::Token token =
|
||||
m->tokenizer.readToken(input, "offset " + std::to_string(input->tell()), true);
|
||||
auto token = m->tokenizer.readToken(input, empty, true);
|
||||
m->filter->handleToken(token);
|
||||
if (token.getType() == QPDFTokenizer::tt_eof) {
|
||||
break;
|
||||
} else if (token.isWord("ID")) {
|
||||
// Read the space after the ID.
|
||||
char ch = ' ';
|
||||
input->read(&ch, 1);
|
||||
input.read(&ch, 1);
|
||||
m->filter->handleToken(
|
||||
// line-break
|
||||
QPDFTokenizer::Token(QPDFTokenizer::tt_space, std::string(1, ch)));
|
||||
|
@ -904,7 +904,7 @@ QPDFTokenizer::readToken(
|
||||
throw QPDFExc(
|
||||
qpdf_e_damaged_pdf,
|
||||
input.getName(),
|
||||
context,
|
||||
context.empty() ? "offset " + std::to_string(input.getLastOffset()) : context,
|
||||
input.getLastOffset(),
|
||||
token.getErrorMessage());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user