Do not copy strings when you don't need it.

This patch removed the use of copy-constructors on the QString to use the
const-references. Even knowing that the QString is a refcounted class,
let's not get that bad habit.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2014-03-19 15:29:13 -03:00 committed by Dirk Hohndel
parent 3d83c48c49
commit 30770f5d85
2 changed files with 7 additions and 7 deletions

View file

@ -138,13 +138,13 @@ void TagWidget::reparse()
}
}
void TagWidget::completionSelected(QString completion)
void TagWidget::completionSelected(const QString& completion)
{
completionHighlighted(completion);
emit textChanged();
}
void TagWidget::completionHighlighted(QString completion)
void TagWidget::completionHighlighted(const QString& completion)
{
QPair<int, int> pos;
pos = getCursorTagPosition();
@ -152,7 +152,7 @@ void TagWidget::completionHighlighted(QString completion)
setText(text().remove(pos.first, pos.second - pos.first).insert(pos.first, completion));
setCursorPosition(pos.first + completion.length());
} else {
setText(completion.append(", "));
setText(completion + QString(", "));
setCursorPosition(text().length());
}
}
@ -164,7 +164,7 @@ void TagWidget::setCursorPosition(int position)
blockSignals(false);
}
void TagWidget::setText(QString text)
void TagWidget::setText(const QString& text)
{
blockSignals(true);
GroupedLineEdit::setText(text);

View file

@ -12,15 +12,15 @@ public:
void setCompleter(QCompleter *completer);
QPair<int, int> getCursorTagPosition();
void highlight();
void setText(QString text);
void setText(const QString& text);
void clear();
void setCursorPosition(int position);
void wheelEvent(QWheelEvent *event);
public
slots:
void reparse();
void completionSelected(QString);
void completionHighlighted(QString);
void completionSelected(const QString& text);
void completionHighlighted(const QString& text);
protected:
void keyPressEvent(QKeyEvent *e);