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>
This commit is contained in:
parent
71a31bd8c8
commit
f4191888eb
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user