QWidget{Text,Line}Control: reserve() a vector

Reduces reallocation overhead.

Change-Id: Ibbb5d6257f78e7f9668b8c7f17aa498f6d4994d3
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
This commit is contained in:
Marc Mutz 2014-02-21 15:18:55 +01:00
parent 88875becb7
commit 5335e6a558
2 changed files with 2 additions and 0 deletions

View File

@ -558,6 +558,7 @@ void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event)
m_preeditCursor = event->preeditString().length();
m_hideCursor = false;
QVector<QTextLayout::FormatRange> formats;
formats.reserve(event->attributes().size());
for (int i = 0; i < event->attributes().size(); ++i) {
const QInputMethodEvent::Attribute &a = event->attributes().at(i);
if (a.type == QInputMethodEvent::Cursor) {

View File

@ -2030,6 +2030,7 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
if (isGettingInput)
layout->setPreeditArea(cursor.position() - block.position(), e->preeditString());
QVector<QTextLayout::FormatRange> overrides;
overrides.reserve(e->attributes().size());
const int oldPreeditCursor = preeditCursor;
preeditCursor = e->preeditString().length();
hideCursor = false;