Skip to content

Commit a20d503

Browse files
committed
Swap QString::replace using trivial QRegExp expressions with simple
QString variants Rationale: 1. It's *much* faster 2. I managed to get a valgrind report from the intermittently crashing PyQgsRulebasedRenderer test, which indicated the crash related to the use of QRegExp in qgsexpressionlexer.ll. Let's see if this has any impact on that crash....
1 parent 7400ca9 commit a20d503

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

src/core/qgsexpressionlexer.ll

+2-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include "qgsexpression.h"
3434
struct expression_parser_context;
3535
#include "qgsexpressionparser.hpp"
36-
#include <QRegExp>
3736
#include <QLocale>
3837

3938
// if not defined, searches for isatty()
@@ -59,7 +58,7 @@ static QString stripText(QString text)
5958
text = text.mid( 1, text.length() - 2 );
6059

6160
// make single "single quotes" from double "single quotes"
62-
text.replace( QRegExp( "''" ), "'" );
61+
text.replace( "''", "'" );
6362

6463
// strip \n \' etc.
6564
int index = 0;
@@ -86,7 +85,7 @@ static QString stripColumnRef(QString text)
8685
text = text.mid( 1, text.length() - 2 );
8786

8887
// make single "double quotes" from double "double quotes"
89-
text.replace( QRegExp( "\"\"" ), "\"" );
88+
text.replace( "\"\"", "\"" );
9089
return text;
9190
}
9291

src/core/qgsvectorlayer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -3600,7 +3600,7 @@ QString QgsVectorLayer::metadata()
36003600
//
36013601
myMetadata += "<p class=\"glossy\">" + tr( "Layer Spatial Reference System" ) + "</p>\n";
36023602
myMetadata += "<p>";
3603-
myMetadata += crs().toProj4().replace( QRegExp( "\"" ), " \"" );
3603+
myMetadata += crs().toProj4().replace( '"', " \"" );
36043604
myMetadata += "</p>\n";
36053605

36063606
//
@@ -3611,7 +3611,7 @@ QString QgsVectorLayer::metadata()
36113611
//myMetadata += "<tr><td bgcolor=\"gray\">";
36123612
myMetadata += "<p class=\"glossy\">" + tr( "Project (Output) Spatial Reference System" ) + "</p>\n";
36133613
myMetadata += "<p>";
3614-
myMetadata += coordinateTransform->destCRS().toProj4().replace( QRegExp( "\"" ), " \"" );
3614+
myMetadata += coordinateTransform->destCRS().toProj4().replace( '"', " \"" );
36153615
myMetadata += "</p>\n";
36163616
#endif
36173617
}

src/plugins/georeferencer/qgsgeorefplugingui.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ bool QgsGeorefPluginGui::loadGCPs( /*bool verbose*/ )
12411241
{
12421242
line = points.readLine();
12431243
QStringList ls;
1244-
if ( line.contains( QRegExp( "," ) ) ) // in previous format "\t" is delimiter of points in new - ","
1244+
if ( line.contains( ',' ) ) // in previous format "\t" is delimiter of points in new - ","
12451245
{
12461246
// points from new georeferencer
12471247
ls = line.split( ',' );

0 commit comments

Comments
 (0)