diff --git a/src/completion/expandingtree/expandingwidgetmodel.cpp b/src/completion/expandingtree/expandingwidgetmodel.cpp --- a/src/completion/expandingtree/expandingwidgetmodel.cpp +++ b/src/completion/expandingtree/expandingwidgetmodel.cpp @@ -50,7 +50,7 @@ clearExpanding(); } -static QColor doAlternate(QColor color) +static QColor doAlternate(const QColor &color) { QColor background = QApplication::palette().window().color(); return KColorUtils::mix(color, background, 0.15); diff --git a/src/completion/katecompletionmodel.h b/src/completion/katecompletionmodel.h --- a/src/completion/katecompletionmodel.h +++ b/src/completion/katecompletionmodel.h @@ -274,7 +274,7 @@ public: explicit Group(const QString &title, int attribute, KateCompletionModel *model); - void addItem(Item i, bool notifyModel = false); + void addItem(const Item &i, bool notifyModel = false); /// Removes the item specified by \a row. Returns true if a change was made to rows. bool removeItem(const ModelRow &row); void resort(); diff --git a/src/completion/katecompletionmodel.cpp b/src/completion/katecompletionmodel.cpp --- a/src/completion/katecompletionmodel.cpp +++ b/src/completion/katecompletionmodel.cpp @@ -1603,7 +1603,7 @@ return ret < 0; } -void KateCompletionModel::Group::addItem(Item i, bool notifyModel) +void KateCompletionModel::Group::addItem(const Item &i, bool notifyModel) { if (isEmpty) { notifyModel = false; diff --git a/src/completion/katecompletionwidget.cpp b/src/completion/katecompletionwidget.cpp --- a/src/completion/katecompletionwidget.cpp +++ b/src/completion/katecompletionwidget.cpp @@ -89,9 +89,9 @@ CALLCI(return, , return, model, aborted(view)); } -static bool _shouldStartCompletion(KTextEditor::CodeCompletionModel *model, KTextEditor::View *view, QString m_automaticInvocationLine, bool m_lastInsertionByUser, const KTextEditor::Cursor &cursor) +static bool _shouldStartCompletion(KTextEditor::CodeCompletionModel *model, KTextEditor::View *view, const QString &automaticInvocationLine, bool m_lastInsertionByUser, const KTextEditor::Cursor &cursor) { - CALLCI(return, , return, model, shouldStartCompletion(view, m_automaticInvocationLine, m_lastInsertionByUser, cursor)); + CALLCI(return, , return, model, shouldStartCompletion(view, automaticInvocationLine, m_lastInsertionByUser, cursor)); } KateCompletionWidget::KateCompletionWidget(KTextEditor::ViewPrivate *parent) diff --git a/src/document/editorconfig.cpp b/src/document/editorconfig.cpp --- a/src/document/editorconfig.cpp +++ b/src/document/editorconfig.cpp @@ -45,7 +45,7 @@ * @return whether a string value could be converted to a integer value. The * value is put in *result. */ -static bool checkIntValue(QString val, int *result) +static bool checkIntValue(const QString &val, int *result) { bool ret(false); *result = val.toInt(&ret); diff --git a/src/document/katedocument.h b/src/document/katedocument.h --- a/src/document/katedocument.h +++ b/src/document/katedocument.h @@ -1179,11 +1179,11 @@ Reads and applies the variables in a single line TODO registered variables gets saved in a [map] */ - void readVariableLine(QString t, bool onlyViewAndRenderer = false); + void readVariableLine(const QString &t, bool onlyViewAndRenderer = false); /** Sets a view variable in all the views. */ - void setViewVariable(QString var, QString val); + void setViewVariable(const QString &var, const QString &val); /** @return weather a string value could be converted to a bool value as supported. @@ -1195,12 +1195,12 @@ to a integer value. The value is put in *result. */ - static bool checkIntValue(QString value, int *result); + static bool checkIntValue(const QString &value, int *result); /** Feeds value into @p col using QColor::setNamedColor() and returns whether the color is valid */ - static bool checkColorValue(QString value, QColor &col); + static bool checkColorValue(const QString &value, QColor &col); bool m_fileChangedDialogsActivated = false; diff --git a/src/document/katedocument.cpp b/src/document/katedocument.cpp --- a/src/document/katedocument.cpp +++ b/src/document/katedocument.cpp @@ -4628,7 +4628,7 @@ } } -void KTextEditor::DocumentPrivate::readVariableLine(QString t, bool onlyViewAndRenderer) +void KTextEditor::DocumentPrivate::readVariableLine(const QString &t, bool onlyViewAndRenderer) { static const QRegularExpression kvLine(QStringLiteral("kate:(.*)")); static const QRegularExpression kvLineWildcard(QStringLiteral("kate-wildcard\\((.*)\\):(.*)")); @@ -4843,7 +4843,7 @@ } } -void KTextEditor::DocumentPrivate::setViewVariable(QString var, QString val) +void KTextEditor::DocumentPrivate::setViewVariable(const QString &var, const QString &val) { bool state; int n; @@ -4911,14 +4911,14 @@ return false; } -bool KTextEditor::DocumentPrivate::checkIntValue(QString val, int *result) +bool KTextEditor::DocumentPrivate::checkIntValue(const QString &val, int *result) { bool ret(false); *result = val.toInt(&ret); return ret; } -bool KTextEditor::DocumentPrivate::checkColorValue(QString val, QColor &c) +bool KTextEditor::DocumentPrivate::checkColorValue(const QString &val, QColor &c) { c.setNamedColor(val); return c.isValid(); diff --git a/src/render/katerenderrange.cpp b/src/render/katerenderrange.cpp --- a/src/render/katerenderrange.cpp +++ b/src/render/katerenderrange.cpp @@ -82,7 +82,7 @@ void NormalRenderRange::addRange(const KTextEditor::Range &range, KTextEditor::Attribute::Ptr attribute) { - m_ranges.push_back(std::make_pair(range, attribute)); + m_ranges.emplace_back(range, std::move(attribute)); } KTextEditor::Cursor NormalRenderRange::nextBoundary() const diff --git a/src/render/katetextlayout.cpp b/src/render/katetextlayout.cpp --- a/src/render/katetextlayout.cpp +++ b/src/render/katetextlayout.cpp @@ -23,7 +23,7 @@ #include "katepartdebug.h" KateTextLayout::KateTextLayout(KateLineLayoutPtr line, int viewLine) - : m_lineLayout(line) + : m_lineLayout(std::move(line)) , m_viewLine(viewLine) , m_startX(m_viewLine ? -1 : 0) { diff --git a/src/schema/katestyletreewidget.cpp b/src/schema/katestyletreewidget.cpp --- a/src/schema/katestyletreewidget.cpp +++ b/src/schema/katestyletreewidget.cpp @@ -325,12 +325,12 @@ void KateStyleTreeWidget::addItem(const QString &styleName, KTextEditor::Attribute::Ptr defaultstyle, KTextEditor::Attribute::Ptr data) { - new KateStyleTreeWidgetItem(this, styleName, defaultstyle, data); + new KateStyleTreeWidgetItem(this, styleName, std::move(defaultstyle), std::move(data)); } void KateStyleTreeWidget::addItem(QTreeWidgetItem *parent, const QString &styleName, KTextEditor::Attribute::Ptr defaultstyle, KTextEditor::Attribute::Ptr data) { - new KateStyleTreeWidgetItem(parent, styleName, defaultstyle, data); + new KateStyleTreeWidgetItem(parent, styleName, std::move(defaultstyle), std::move(data)); updateGroupHeadings(); } // END @@ -405,18 +405,18 @@ KateStyleTreeWidgetItem::KateStyleTreeWidgetItem(QTreeWidgetItem *parent, const QString &stylename, KTextEditor::Attribute::Ptr defaultAttribute, KTextEditor::Attribute::Ptr actualAttribute) : QTreeWidgetItem(parent) , currentStyle(nullptr) - , defaultStyle(defaultAttribute) - , actualStyle(actualAttribute) + , defaultStyle(std::move(defaultAttribute)) + , actualStyle(std::move(actualAttribute)) { initStyle(); setText(0, stylename); } KateStyleTreeWidgetItem::KateStyleTreeWidgetItem(QTreeWidget *parent, const QString &stylename, KTextEditor::Attribute::Ptr defaultAttribute, KTextEditor::Attribute::Ptr actualAttribute) : QTreeWidgetItem(parent) , currentStyle(nullptr) - , defaultStyle(defaultAttribute) - , actualStyle(actualAttribute) + , defaultStyle(std::move(defaultAttribute)) + , actualStyle(std::move(actualAttribute)) { initStyle(); setText(0, stylename); diff --git a/src/script/katecommandlinescript.h b/src/script/katecommandlinescript.h --- a/src/script/katecommandlinescript.h +++ b/src/script/katecommandlinescript.h @@ -69,7 +69,7 @@ const KateCommandLineScriptHeader &commandHeader(); - bool callFunction(const QString &cmd, const QStringList args, QString &errorMessage); + bool callFunction(const QString &cmd, const QStringList &args, QString &errorMessage); // // KTextEditor::Command interface diff --git a/src/script/katecommandlinescript.cpp b/src/script/katecommandlinescript.cpp --- a/src/script/katecommandlinescript.cpp +++ b/src/script/katecommandlinescript.cpp @@ -47,7 +47,7 @@ return m_commandHeader; } -bool KateCommandLineScript::callFunction(const QString &cmd, const QStringList args, QString &errorMessage) +bool KateCommandLineScript::callFunction(const QString &cmd, const QStringList &args, QString &errorMessage) { clearExceptions(); QJSValue command = function(cmd); diff --git a/src/search/katesearchbar.cpp b/src/search/katesearchbar.cpp --- a/src/search/katesearchbar.cpp +++ b/src/search/katesearchbar.cpp @@ -98,7 +98,7 @@ m_menu->setEnabled(enabled); } - void addEntry(const QString &before, const QString after, const QString description, const QString &realBefore = QString(), const QString &realAfter = QString()) + void addEntry(const QString &before, const QString &after, const QString &description, const QString &realBefore = QString(), const QString &realAfter = QString()) { if (m_menu == nullptr) { return; diff --git a/src/utils/attribute.cpp b/src/utils/attribute.cpp --- a/src/utils/attribute.cpp +++ b/src/utils/attribute.cpp @@ -90,7 +90,7 @@ return; } - d->dynamicAttributes[type] = attribute; + d->dynamicAttributes[type] = std::move(attribute); } QString Attribute::name() const diff --git a/src/utils/katecmd.cpp b/src/utils/katecmd.cpp --- a/src/utils/katecmd.cpp +++ b/src/utils/katecmd.cpp @@ -38,7 +38,7 @@ bool KateCmd::registerCommand(KTextEditor::Command *cmd) { - const QStringList l = cmd->cmds(); + const QStringList &l = cmd->cmds(); for (int z = 0; z < l.count(); z++) if (m_dict.contains(l[z])) { diff --git a/src/utils/kateglobal.cpp b/src/utils/kateglobal.cpp --- a/src/utils/kateglobal.cpp +++ b/src/utils/kateglobal.cpp @@ -550,7 +550,7 @@ auto applicationConfig = KSharedConfig::openConfig(); if (!KConfigGroup(applicationConfig, QStringLiteral("KTextEditor Editor")).exists()) { auto globalConfig = KSharedConfig::openConfig(QStringLiteral("katepartrc")); - for (auto group : {QStringLiteral("Editor"), QStringLiteral("Document"), QStringLiteral("View"), QStringLiteral("Renderer")}) { + for (const auto &group : {QStringLiteral("Editor"), QStringLiteral("Document"), QStringLiteral("View"), QStringLiteral("Renderer")}) { KConfigGroup origin(globalConfig, group); KConfigGroup destination(applicationConfig, QStringLiteral("KTextEditor ") + group); origin.copyTo(&destination); diff --git a/src/utils/variable.cpp b/src/utils/variable.cpp --- a/src/utils/variable.cpp +++ b/src/utils/variable.cpp @@ -23,7 +23,7 @@ Variable::Variable(const QString &name, const QString &description, Variable::ExpandFunction func, bool isPrefixMatch) : m_name(name) , m_description(description) - , m_function(func) + , m_function(std::move(func)) , m_isPrefixMatch(isPrefixMatch) { } diff --git a/src/view/katemessagewidget.cpp b/src/view/katemessagewidget.cpp --- a/src/view/katemessagewidget.cpp +++ b/src/view/katemessagewidget.cpp @@ -184,7 +184,7 @@ void KateMessageWidget::postMessage(KTextEditor::Message *message, QList> actions) { Q_ASSERT(!m_messageHash.contains(message)); - m_messageHash[message] = actions; + m_messageHash[message] = std::move(actions); // insert message sorted after priority int i = 0; diff --git a/src/view/katestatusbar.cpp b/src/view/katestatusbar.cpp --- a/src/view/katestatusbar.cpp +++ b/src/view/katestatusbar.cpp @@ -325,7 +325,7 @@ // Check if at the current cursor position is a special dictionary in use KTextEditor::Cursor position(m_view->cursorPositionVirtual()); const QList> dictRanges = m_view->doc()->dictionaryRanges(); - for (auto rangeDictPair : dictRanges) { + for (const auto &rangeDictPair : dictRanges) { const KTextEditor::MovingRange *range = rangeDictPair.first; if (range->contains(position) || range->end() == position) { newDict = rangeDictPair.second; diff --git a/src/view/katetextanimation.cpp b/src/view/katetextanimation.cpp --- a/src/view/katetextanimation.cpp +++ b/src/view/katetextanimation.cpp @@ -33,7 +33,7 @@ KateTextAnimation::KateTextAnimation(const KTextEditor::Range &range, KTextEditor::Attribute::Ptr attribute, KateViewInternal *view) : QObject(view) , m_range(range) - , m_attribute(attribute) + , m_attribute(std::move(attribute)) , m_doc(view->view()->doc()) , m_view(view) , m_timeLine(new QTimeLine(250, this)) diff --git a/src/view/kateview.cpp b/src/view/kateview.cpp --- a/src/view/kateview.cpp +++ b/src/view/kateview.cpp @@ -3693,7 +3693,7 @@ connect(this, SIGNAL(displayRangeChanged(KTextEditor::ViewPrivate *)), messageWidget, SLOT(startAutoHideTimer())); connect(this, SIGNAL(cursorPositionChanged(KTextEditor::View *, KTextEditor::Cursor)), messageWidget, SLOT(startAutoHideTimer())); } - messageWidget->postMessage(message, actions); + messageWidget->postMessage(message, std::move(actions)); } KateMessageWidget *KTextEditor::ViewPrivate::messageWidget() diff --git a/src/view/kateviewinternal.cpp b/src/view/kateviewinternal.cpp --- a/src/view/kateviewinternal.cpp +++ b/src/view/kateviewinternal.cpp @@ -3773,7 +3773,7 @@ m_imPreeditRangeChildren.clear(); int decorationColumn = 0; - const auto attributes = e->attributes(); + const auto &attributes = e->attributes(); for (auto &a : attributes) { if (a.type == QInputMethodEvent::Cursor) { newCursor = m_imPreeditRange->start() + KTextEditor::Cursor(0, a.start); @@ -3824,7 +3824,7 @@ if (m_textAnimation) { m_textAnimation->deleteLater(); } - m_textAnimation = new KateTextAnimation(range, attribute, this); + m_textAnimation = new KateTextAnimation(range, std::move(attribute), this); } void KateViewInternal::documentTextInserted(KTextEditor::Document *document, const KTextEditor::Range &range) diff --git a/src/vimode/command.h b/src/vimode/command.h --- a/src/vimode/command.h +++ b/src/vimode/command.h @@ -43,7 +43,7 @@ class Command { public: - Command(NormalViMode *parent, QString pattern, bool (NormalViMode::*pt2Func)(), unsigned int flags = 0); + Command(NormalViMode *parent, const QString &pattern, bool (NormalViMode::*pt2Func)(), unsigned int flags = 0); ~Command(); bool matches(const QString &pattern) const; diff --git a/src/vimode/command.cpp b/src/vimode/command.cpp --- a/src/vimode/command.cpp +++ b/src/vimode/command.cpp @@ -25,7 +25,7 @@ using namespace KateVi; -Command::Command(NormalViMode *parent, QString pattern, bool (NormalViMode::*commandMethod)(), unsigned int flags) +Command::Command(NormalViMode *parent, const QString &pattern, bool (NormalViMode::*commandMethod)(), unsigned int flags) { m_parent = parent; m_pattern = KeyParser::self()->encodeKeySequence(pattern); diff --git a/src/vimode/modes/modebase.h b/src/vimode/modes/modebase.h --- a/src/vimode/modes/modebase.h +++ b/src/vimode/modes/modebase.h @@ -84,7 +84,7 @@ protected: // helper methods - void yankToClipBoard(QChar chosen_register, QString text); + void yankToClipBoard(QChar chosen_register, const QString &text); bool deleteRange(Range &r, OperationMode mode = LineWise, bool addToRegister = true); const QString getRange(Range &r, OperationMode mode = LineWise) const; const QString getLine(int line = -1) const; diff --git a/src/vimode/modes/modebase.cpp b/src/vimode/modes/modebase.cpp --- a/src/vimode/modes/modebase.cpp +++ b/src/vimode/modes/modebase.cpp @@ -57,7 +57,7 @@ // HELPER METHODS //////////////////////////////////////////////////////////////////////////////// -void ModeBase::yankToClipBoard(QChar chosen_register, QString text) +void ModeBase::yankToClipBoard(QChar chosen_register, const QString &text) { // only yank to the clipboard if no register was specified, // textlength > 1 and there is something else then whitespace @@ -328,17 +328,15 @@ { QString line = getLine(fromLine); - QRegExp endOfWORDPattern(QLatin1String("\\S\\s|\\S$|^$")); - - QRegExp endOfWORD(endOfWORDPattern); + const QRegExp endOfWORDPattern(QLatin1String("\\S\\s|\\S$|^$")); int l = fromLine; int c = fromColumn; bool found = false; while (!found) { - int c1 = endOfWORD.lastIndexIn(line, c - 1); + int c1 = endOfWORDPattern.lastIndexIn(line, c - 1); if (c1 != -1 && c - 1 != -1) { found = true;