QTextDocument: avoid relocations
Hand-roll a string table here, since there's opportunity for sharing string data between string entries. Effects on Linux AMD64 GCC 4.9-trunk release stripped: text: -88B data: -64B relocs: -5 Maintainability is hurt somewhat, but it is expected that the contents of this string table do not change much, so the overall effect is still very low. Change-Id: I2a22da4c8548c53ef31c33319b4652f3cb6f62f5 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
This commit is contained in:
parent
883444f16b
commit
e14503d353
@ -2160,13 +2160,21 @@ bool QTextHtmlExporter::emitCharFormatStyle(const QTextCharFormat &format)
|
||||
html += QLatin1String("pt;");
|
||||
attributesEmitted = true;
|
||||
} else if (format.hasProperty(QTextFormat::FontSizeAdjustment)) {
|
||||
static const char * const sizeNames[] = {
|
||||
"small", "medium", "large", "x-large", "xx-large"
|
||||
static const char sizeNameData[] =
|
||||
"small" "\0"
|
||||
"medium" "\0"
|
||||
"xx-large" ;
|
||||
static const quint8 sizeNameOffsets[] = {
|
||||
0, // "small"
|
||||
sizeof("small"), // "medium"
|
||||
sizeof("small") + sizeof("medium") + 3, // "large" )
|
||||
sizeof("small") + sizeof("medium") + 1, // "x-large" )> compressed into "xx-large"
|
||||
sizeof("small") + sizeof("medium"), // "xx-large" )
|
||||
};
|
||||
const char *name = 0;
|
||||
const int idx = format.intProperty(QTextFormat::FontSizeAdjustment) + 1;
|
||||
if (idx >= 0 && idx <= 4) {
|
||||
name = sizeNames[idx];
|
||||
name = sizeNameData + sizeNameOffsets[idx];
|
||||
}
|
||||
if (name) {
|
||||
html += QLatin1String(" font-size:");
|
||||
|
Loading…
Reference in New Issue
Block a user