Skip to content

Commit

Permalink
Swap QString::replace using trivial QRegExp expressions with simple
Browse files Browse the repository at this point in the history
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 a20d503
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/core/qgsexpressionlexer.ll
Expand Up @@ -33,7 +33,6 @@
#include "qgsexpression.h"
struct expression_parser_context;
#include "qgsexpressionparser.hpp"
#include <QRegExp>
#include <QLocale>

// if not defined, searches for isatty()
Expand All @@ -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;
Expand All @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -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";

//
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/georeferencer/qgsgeorefplugingui.cpp
Expand Up @@ -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( ',' );
Expand Down

0 comments on commit a20d503

Please sign in to comment.