From c5af948623bd67a4d437fa1374e5f3a67ed3fc25 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Thu, 22 May 2014 23:34:05 +0300 Subject: CppTools: Optimize test for electric char in context Change-Id: I34a03ec9e781656fd4f24a719fb2c2da2efa4681 Reviewed-by: Erik Verbruggen --- src/plugins/cpptools/cppqtstyleindenter.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/plugins/cpptools/cppqtstyleindenter.cpp') diff --git a/src/plugins/cpptools/cppqtstyleindenter.cpp b/src/plugins/cpptools/cppqtstyleindenter.cpp index eb557a9bde..1b8ccb66fc 100644 --- a/src/plugins/cpptools/cppqtstyleindenter.cpp +++ b/src/plugins/cpptools/cppqtstyleindenter.cpp @@ -84,9 +84,12 @@ static bool isElectricInLine(const QChar ch, const QString &text) // lines that start with : might have a constructor initializer list case '<': case '>': { - // Electrical if at line beginning (after space indentation) - const QString trimmedtext = text.trimmed(); - return !trimmedtext.isEmpty() && trimmedtext.at(0) == ch; + // Electric if at line beginning (after space indentation) + for (int i = 0, len = text.count(); i < len; ++i) { + if (!text.at(i).isSpace()) + return text.at(i) == ch; + } + return false; } } -- cgit v1.2.1