summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextdocument.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2013-10-11 00:12:27 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-23 19:37:41 +0100
commite14503d353de7246a1d6e36894dd77bb32c4af3b (patch)
tree6cfe22641462ad190598e878bbf8988a7d463575 /src/gui/text/qtextdocument.cpp
parent883444f16b22a020821e9e699da6277b946fa501 (diff)
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>
Diffstat (limited to 'src/gui/text/qtextdocument.cpp')
-rw-r--r--src/gui/text/qtextdocument.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index 82d63237e7..fa54776b6d 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -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:");