diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2016-11-10 12:45:49 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2016-11-10 16:14:51 +0000 |
commit | 467b15a20c3d6eb611ea5f6ccffd5fc0df81b0c4 (patch) | |
tree | 1bff11fa019cebd2242c856301b7bd28462a9f6c /src/gui/text/qtextlayout.cpp | |
parent | 5cff7d2b679d48a247b4630cb9e3d5b04fab0b55 (diff) |
Improve use of QHash to minimize double hashing
Avoid looking up by key twice in a row in various locations, but instead
using iterators and index lookup.
Change-Id: I61a079115199ab9c041ad3a26d36b45ee3f775e0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/gui/text/qtextlayout.cpp')
-rw-r--r-- | src/gui/text/qtextlayout.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index f5827bb683..28a5eb6a89 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1059,9 +1059,10 @@ QList<QGlyphRun> QTextLayout::glyphRuns(int from, int length) const QGlyphRun::GlyphRunFlags flags = glyphRun.flags(); QPair<QFontEngine *, int> key(fontEngine, int(flags)); // merge the glyph runs using the same font - if (glyphRunHash.contains(key)) { - QGlyphRun &oldGlyphRun = glyphRunHash[key]; - + QGlyphRun &oldGlyphRun = glyphRunHash[key]; + if (oldGlyphRun.isEmpty()) { + oldGlyphRun = glyphRun; + } else { QVector<quint32> indexes = oldGlyphRun.glyphIndexes(); QVector<QPointF> positions = oldGlyphRun.positions(); QRectF boundingRect = oldGlyphRun.boundingRect(); @@ -1073,8 +1074,6 @@ QList<QGlyphRun> QTextLayout::glyphRuns(int from, int length) const oldGlyphRun.setGlyphIndexes(indexes); oldGlyphRun.setPositions(positions); oldGlyphRun.setBoundingRect(boundingRect); - } else { - glyphRunHash[key] = glyphRun; } } } |