Skip to content
Permalink
Browse files

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....
  • Loading branch information
nyalldawson committed Jan 25, 2016
1 parent 7400ca9 commit a20d50340d906f64a9401103da10614a234c54c8
@@ -33,7 +33,6 @@
#include "qgsexpression.h"
struct expression_parser_context;
#include "qgsexpressionparser.hpp"
#include <QRegExp>
#include <QLocale>

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

// make single "single quotes" from double "single quotes"
text.replace( QRegExp( "''" ), "'" );
text.replace( "''", "'" );

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

// make single "double quotes" from double "double quotes"
text.replace( QRegExp( "\"\"" ), "\"" );
text.replace( "\"\"", "\"" );
return text;
}

@@ -3600,7 +3600,7 @@ QString QgsVectorLayer::metadata()
//
myMetadata += "<p class=\"glossy\">" + tr( "Layer Spatial Reference System" ) + "</p>\n";
myMetadata += "<p>";
myMetadata += crs().toProj4().replace( QRegExp( "\"" ), " \"" );
myMetadata += crs().toProj4().replace( '"', " \"" );
myMetadata += "</p>\n";

//
@@ -3611,7 +3611,7 @@ QString QgsVectorLayer::metadata()
//myMetadata += "<tr><td bgcolor=\"gray\">";
myMetadata += "<p class=\"glossy\">" + tr( "Project (Output) Spatial Reference System" ) + "</p>\n";
myMetadata += "<p>";
myMetadata += coordinateTransform->destCRS().toProj4().replace( QRegExp( "\"" ), " \"" );
myMetadata += coordinateTransform->destCRS().toProj4().replace( '"', " \"" );
myMetadata += "</p>\n";
#endif
}
@@ -1241,7 +1241,7 @@ bool QgsGeorefPluginGui::loadGCPs( /*bool verbose*/ )
{
line = points.readLine();
QStringList ls;
if ( line.contains( QRegExp( "," ) ) ) // in previous format "\t" is delimiter of points in new - ","
if ( line.contains( ',' ) ) // in previous format "\t" is delimiter of points in new - ","
{
// points from new georeferencer
ls = line.split( ',' );

0 comments on commit a20d503

Please sign in to comment.
You can’t perform that action at this time.