summaryrefslogtreecommitdiffstats
path: root/src/printsupport/kernel
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2013-12-11 10:47:00 +0100
committerMarc Mutz <marc.mutz@kdab.com>2014-11-25 16:37:08 +0100
commitf4191888eb6355c5a63fdc20d144e9afa6910950 (patch)
tree57ac3d2383d59a8d8a1caa497def4bda7f6dfa73 /src/printsupport/kernel
parent71a31bd8c8e3ef9689b31dc78556b885380ea6a6 (diff)
QCups: avoid relocations
Replace a string (pointer) table with arrays of char arrays of maximally occurring size. In the pageLayoutData case, this is trivial, since all strings have the same size. In the pagesPerSheetData case, I've used a trick to cram the (only) two-digit number into a char[2] array, by following it with a null entry. Effects on AMD64 Linux GCC 4.7 release stripped: text: -352B data: -160B relocs: -14 Change-Id: I6c458ff7ada0f45dab976bbe42b24757fc321302 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/printsupport/kernel')
-rw-r--r--src/printsupport/kernel/qcups.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp
index 1a27fbd07c..b8f75c3cb7 100644
--- a/src/printsupport/kernel/qcups.cpp
+++ b/src/printsupport/kernel/qcups.cpp
@@ -168,8 +168,11 @@ void QCUPSSupport::setPagesPerSheetLayout(QPrinter *printer, const PagesPerShee
const PagesPerSheetLayout pagesPerSheetLayout)
{
QStringList cupsOptions = cupsOptionsList(printer);
- static const char *pagesPerSheetData[] = { "1", "2", "4", "6", "9", "16", 0 };
- static const char *pageLayoutData[] = {"lrtb", "lrbt", "rlbt", "rltb", "btlr", "btrl", "tblr", "tbrl", 0};
+ // WARNING: the following trick (with a [2]-extent) only works as
+ // WARNING: long as there's only one two-digit number in the list
+ // WARNING: and it is the last one (before the "\0")!
+ static const char pagesPerSheetData[][2] = { "1", "2", "4", "6", "9", {'1', '6'}, "\0" };
+ static const char pageLayoutData[][5] = {"lrtb", "lrbt", "rlbt", "rltb", "btlr", "btrl", "tblr", "tbrl"};
setCupsOption(cupsOptions, QStringLiteral("number-up"), QLatin1String(pagesPerSheetData[pagesPerSheet]));
setCupsOption(cupsOptions, QStringLiteral("number-up-layout"), QLatin1String(pageLayoutData[pagesPerSheetLayout]));
setCupsOptions(printer, cupsOptions);