diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2014-02-03 02:44:46 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-07 15:31:55 +0100 |
commit | 4e319ca4c47a99295c1a07aa759e09d86f1b7c87 (patch) | |
tree | c6e8591798db0e795c9efc60a450927341ad4501 /src/gui/painting/qpainter.cpp | |
parent | 93aec932ff6471b39cd3b577079407f145996ec2 (diff) |
Optimize stringToCMap() usage
CMAP guarantees there is 1:1 mapping between the Unicode code points
array and the glyph indexes array, which means the QString length
always greater than or equal to a sufficient glyph indexes array length.
Simply add some asserts and improve the memory consumption
and the performance where possible.
Change-Id: I0bc8cdba5f86c1c0ba9e79c8d5f96cbe56ec463e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/gui/painting/qpainter.cpp')
-rw-r--r-- | src/gui/painting/qpainter.cpp | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 2944130eaa..1fc044aa44 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -5845,11 +5845,8 @@ void QPainter::drawText(const QPointF &p, const QString &str, int tf, int justif int numGlyphs = len; QVarLengthGlyphLayoutArray glyphs(len); QFontEngine *fontEngine = d->state->font.d->engineForScript(QChar::Script_Common); - if (!fontEngine->stringToCMap(str.data(), len, &glyphs, &numGlyphs, 0)) { - glyphs.resize(numGlyphs); - if (!fontEngine->stringToCMap(str.data(), len, &glyphs, &numGlyphs, 0)) - Q_ASSERT_X(false, Q_FUNC_INFO, "stringToCMap shouldn't fail twice"); - } + if (!fontEngine->stringToCMap(str.data(), len, &glyphs, &numGlyphs, 0)) + Q_UNREACHABLE(); QTextItemInt gf(glyphs, &d->state->font, str.data(), len, fontEngine); drawTextItem(p, gf); |