!30 Tune QUtil::hex_encode

From: @lixiaoyong1 
Reviewed-by: @caodongxia 
Signed-off-by: @caodongxia
This commit is contained in:
openeuler-ci-bot 2024-05-20 09:28:36 +00:00 committed by Gitee
commit 9f1bb89100
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 40 additions and 2 deletions

View File

@ -0,0 +1,33 @@
From ae800361fefb6d30d054f5d90af310c85765b044 Mon Sep 17 00:00:00 2001
From: m-holger <m-holger@kubitscheck.org>
Date: Thu, 22 Sep 2022 20:13:51 +0100
Subject: [PATCH] Tune QUtil::hex_encode
Reference: https://github.com/qpdf/qpdf/commit/ae800361fefb6d30d054f5d90af310c85765b044
---
libqpdf/QUtil.cc | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/libqpdf/QUtil.cc b/libqpdf/QUtil.cc
index 98a8f318..bcf4aa4e 100644
--- a/libqpdf/QUtil.cc
+++ b/libqpdf/QUtil.cc
@@ -769,10 +769,12 @@ QUtil::make_unique_cstr(std::string const& str)
std::string
QUtil::hex_encode(std::string const& input)
{
+ static auto constexpr hexchars = "0123456789abcdef";
std::string result;
- for (unsigned int i = 0; i < input.length(); ++i) {
- result += QUtil::int_to_string_base(
- QIntC::to_int(static_cast<unsigned char>(input.at(i))), 16, 2);
+ result.reserve(2 * input.length());
+ for (const char c: input) {
+ result += hexchars[static_cast<unsigned char>(c) >> 4];
+ result += hexchars[c & 0x0f];
}
return result;
}
--
2.39.3

View File

@ -1,11 +1,13 @@
Name: qpdf
Version: 11.1.0
Release: 2
Release: 3
Summary: A command-line program to transform PDF files
License: (Artistic 2.0 or ASL 2.0) and MIT
URL: http://qpdf.sourceforge.net/
Source0: http://downloads.sourceforge.net/sourceforge/qpdf/qpdf-%{version}.tar.gz
Patch0001: 0001-Tune-QUtil-hex_encode.patch
BuildRequires: gcc gcc-c++ zlib-devel libjpeg-turbo-devel pcre-devel
BuildRequires: perl-interpreter perl-generators perl(Digest::MD5)
BuildRequires: cmake gnutls-devel
@ -37,7 +39,7 @@ Obsoletes: %{name}-doc < %{version}-%{release}
This package contains some man help and other files for %{name}.
%prep
%setup -q
%autosetup -n %{name}-%{version} -p1
%build
export CFLAGS="${RPM_OPT_FLAGS}"
@ -86,6 +88,9 @@ rm -rf %{buildroot}/usr/lib64/libqpdf.a
%{_mandir}/man1/*
%changelog
* Fri May 10 2024 lixiaoyong <lixiaoyong@kylinos.cn> - 11.1.0-3
- Tune QUtil::hex_encode
* Mon Mar 06 2023 wangkai <wangkai385@h-partners.com> - 11.1.0-2
- Add BIND_NOW,PIE,SP secure compilation options