From fbb4befa33196e04bc25e62bbf43f0d3a1d0846b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 28 Aug 2018 09:29:00 +0200 Subject: Remove dead code in QWin32PrintEngine The functions checks for _glyphs.isEmpty() and returns in that case, so, there is no point in having another code branch for _glyphs.size() == 0 below. Unindent branch for _glyphs.size() > 0 and brush it up a bit to silence clang-tidy (warnings about using isEmpty(), nullptr). Change-Id: I78e86583bb30c7bea1357e7a45f61b07d5a4d139 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/printsupport/kernel/qprintengine_win.cpp | 43 ++++++++++------------------ 1 file changed, 15 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp index 6f263e5ea8..5ee93a46b3 100644 --- a/src/printsupport/kernel/qprintengine_win.cpp +++ b/src/printsupport/kernel/qprintengine_win.cpp @@ -1779,39 +1779,26 @@ static void draw_text_item_win(const QPointF &pos, const QTextItemInt &ti, HDC h QTransform matrix = QTransform::fromTranslate(baseline_pos.x(), baseline_pos.y()); ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, _glyphs, positions); - if (_glyphs.size() == 0) { + if (_glyphs.isEmpty()) { SelectObject(hdc, old_font); return; } - bool outputEntireItem = _glyphs.size() > 0; - - if (outputEntireItem) { - options |= ETO_PDY; - QVarLengthArray glyphDistances(_glyphs.size() * 2); - QVarLengthArray g(_glyphs.size()); - for (int i=0; i<_glyphs.size() - 1; ++i) { - glyphDistances[i * 2] = qRound(positions[i + 1].x) - qRound(positions[i].x); - glyphDistances[i * 2 + 1] = qRound(positions[i + 1].y) - qRound(positions[i].y); - g[i] = _glyphs[i]; - } - glyphDistances[(_glyphs.size() - 1) * 2] = 0; - glyphDistances[(_glyphs.size() - 1) * 2 + 1] = 0; - g[_glyphs.size() - 1] = _glyphs[_glyphs.size() - 1]; - ExtTextOut(hdc, qRound(positions[0].x), qRound(positions[0].y), options, 0, - g.constData(), _glyphs.size(), - glyphDistances.data()); - } else { - int i = 0; - while(i < _glyphs.size()) { - wchar_t g = _glyphs[i]; - - ExtTextOut(hdc, qRound(positions[i].x), - qRound(positions[i].y), options, 0, - &g, 1, 0); - ++i; - } + options |= ETO_PDY; + QVarLengthArray glyphDistances(_glyphs.size() * 2); + QVarLengthArray g(_glyphs.size()); + const int lastGlyph = _glyphs.size() - 1; + for (int i = 0; i < lastGlyph; ++i) { + glyphDistances[i * 2] = qRound(positions[i + 1].x) - qRound(positions[i].x); + glyphDistances[i * 2 + 1] = qRound(positions[i + 1].y) - qRound(positions[i].y); + g[i] = _glyphs[i]; } + glyphDistances[lastGlyph * 2] = 0; + glyphDistances[lastGlyph * 2 + 1] = 0; + g[lastGlyph] = _glyphs[lastGlyph]; + ExtTextOut(hdc, qRound(positions[0].x), qRound(positions[0].y), options, nullptr, + g.constData(), _glyphs.size(), + glyphDistances.data()); } win_xform.eM11 = win_xform.eM22 = 1.0; -- cgit v1.2.3