From e4073ee868da50a7c5197d5f95e3cf64895b2b4d Mon Sep 17 00:00:00 2001 From: m-holger Date: Tue, 23 Aug 2022 19:37:31 +0100 Subject: Remove unnecessary string copy in QPDFTokenizer::getToken --- libqpdf/QPDFTokenizer.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'libqpdf/QPDFTokenizer.cc') diff --git a/libqpdf/QPDFTokenizer.cc b/libqpdf/QPDFTokenizer.cc index 07f6bfb7..6e492f2b 100644 --- a/libqpdf/QPDFTokenizer.cc +++ b/libqpdf/QPDFTokenizer.cc @@ -951,12 +951,11 @@ QPDFTokenizer::getToken(Token& token, bool& unread_char, char& ch) unread_char = !this->in_token && !this->before_token; ch = this->char_to_unread; if (ready) { - if (this->type == tt_bad) { - this->val.clear(); - this->val += this->raw_val; - } - token = - Token(this->type, this->val, this->raw_val, this->error_message); + token = (this->type == tt_bad) + ? Token( + this->type, this->raw_val, this->raw_val, this->error_message) + : Token(this->type, this->val, this->raw_val, this->error_message); + this->reset(); } return ready; -- cgit v1.2.3-70-g09d2