diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2014-02-21 15:18:55 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-05-30 15:00:40 +0000 |
commit | 5335e6a558a0aa8b86b9c564f91c6ec10380c7af (patch) | |
tree | 9aaa3436ee53ee764e5eed73ef547a39cc4680b6 /src/widgets/widgets | |
parent | 88875becb78a06f9192f15fd0aaef1ac80f810c3 (diff) |
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>
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r-- | src/widgets/widgets/qwidgetlinecontrol.cpp | 1 | ||||
-rw-r--r-- | src/widgets/widgets/qwidgettextcontrol.cpp | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index 3cd0277f77..436937be72 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -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) { diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index a46abf374d..22d199fc74 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -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; |