diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-06-08 00:17:53 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-07-12 06:56:02 +0200 |
commit | 46d257b19d677e4e4b2a24624716af2207dd9759 (patch) | |
tree | 0abd15a3541be62c21c1c4a6b56696dae2d5f41d /src/gui/painting/qpdf.cpp | |
parent | 56fbcfd2b78bc62eca953a5cd3af831a8964e9e1 (diff) |
QPdfEngine: replace a QHash with a C array
The mapping is completely static and the key is the index, so just use
a const char array. The only twist here is that to avoid relocations,
we use an array of const char[4] instead of const char*[].
Change-Id: I001b4db833f14e000676125f6f1be4484d996e0b
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/gui/painting/qpdf.cpp')
-rw-r--r-- | src/gui/painting/qpdf.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 25d488961c..f560e1f0f0 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1570,12 +1570,14 @@ void QPdfEnginePrivate::writeHeader() { addXrefEntry(0,false); - static const QHash<QPdfEngine::PdfVersion, const char *> mapping { - {QPdfEngine::Version_1_4, "1.4"}, - {QPdfEngine::Version_A1b, "1.4"}, - {QPdfEngine::Version_1_6, "1.6"} + // Keep in sync with QPdfEngine::PdfVersion! + static const char mapping[][4] = { + "1.4", // Version_1_4 + "1.4", // Version_A1b + "1.6", // Version_1_6 }; - const char *verStr = mapping.value(pdfVersion, "1.4"); + static const size_t numMappings = sizeof mapping / sizeof *mapping; + const char *verStr = mapping[size_t(pdfVersion) < numMappings ? pdfVersion : 0]; xprintf("%%PDF-%s\n", verStr); xprintf("%%\303\242\303\243\n"); |