Skip to content

Commit

Permalink
thread_local
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn authored and github-actions[bot] committed May 11, 2021
1 parent 9a75ead commit e32b1fc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 28 deletions.
6 changes: 2 additions & 4 deletions src/core/expression/qgsexpressionnodeimpl.cpp
Expand Up @@ -558,8 +558,7 @@ QVariant QgsExpressionNodeBinaryOperator::evalNode( QgsExpression *parent, const
esc_regexp.replace( pos + 1, 1, '.' );
pos += 1;
}
const static QRegularExpression sRx4( QStringLiteral( "\\\\_" ) );
QRegularExpression rx4( sRx4 );
const thread_local QRegularExpression rx4( QStringLiteral( "\\\\_" ) );
esc_regexp.replace( rx4, QStringLiteral( "_" ) );
matches = QRegExp( esc_regexp, mOp == boLike || mOp == boNotLike ? Qt::CaseSensitive : Qt::CaseInsensitive ).exactMatch( str );
}
Expand Down Expand Up @@ -1364,8 +1363,7 @@ bool QgsExpressionNodeColumnRef::prepareNode( QgsExpression *parent, const QgsEx

QString QgsExpressionNodeColumnRef::dump() const
{
const static QRegularExpression sRe( QStringLiteral( "^[A-Za-z_\x80-\xff][A-Za-z0-9_\x80-\xff]*$" ) );
QRegularExpression re( sRe );
const thread_local QRegularExpression re( QStringLiteral( "^[A-Za-z_\x80-\xff][A-Za-z0-9_\x80-\xff]*$" ) );
return re.match( mName ).hasMatch() ? mName : QgsExpression::quotedColumnRef( mName );
}

Expand Down
3 changes: 1 addition & 2 deletions src/core/geometry/qgsmultipoint.cpp
Expand Up @@ -65,8 +65,7 @@ bool QgsMultiPoint::fromWkt( const QString &wkt )
{
QString collectionWkt( wkt );
//test for non-standard MultiPoint(x1 y1, x2 y2) format
static const QRegularExpression sRegex( QStringLiteral( "^\\s*MultiPoint\\s*[ZM]*\\s*\\(\\s*[-\\d]" ), QRegularExpression::CaseInsensitiveOption );
QRegularExpression regex( sRegex );
const thread_local QRegularExpression regex( QStringLiteral( "^\\s*MultiPoint\\s*[ZM]*\\s*\\(\\s*[-\\d]" ), QRegularExpression::CaseInsensitiveOption );
const QRegularExpressionMatch match = regex.match( collectionWkt );
if ( match.hasMatch() )
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsapplication.cpp
Expand Up @@ -874,7 +874,7 @@ void QgsApplication::setUITheme( const QString &themeName )
{
// apply OS-specific UI scale factor to stylesheet's em values
int index = 0;
QRegularExpression regex( QStringLiteral( "(?<=[\\s:])([0-9\\.]+)(?=em)" ) );
const thread_local QRegularExpression regex( QStringLiteral( "(?<=[\\s:])([0-9\\.]+)(?=em)" ) );
QRegularExpressionMatch match = regex.match( styledata, index );
while ( match.hasMatch() )
{
Expand Down Expand Up @@ -1091,7 +1091,7 @@ QString QgsApplication::userStylePath()

QRegExp QgsApplication::shortNameRegExp()
{
static const QRegExp regexp( QStringLiteral( "^[A-Za-z][A-Za-z0-9\\._-]*" ) );
const thread_local QRegExp regexp( QStringLiteral( "^[A-Za-z][A-Za-z0-9\\._-]*" ) );
return regexp;
}

Expand Down
28 changes: 10 additions & 18 deletions src/core/qgscoordinatereferencesystem.cpp
Expand Up @@ -290,8 +290,7 @@ bool QgsCoordinateReferenceSystem::createFromString( const QString &definition )
locker.unlock();

bool result = false;
const static QRegularExpression sReCrsId( QStringLiteral( "^(epsg|esri|osgeo|ignf|zangi|iau2000|postgis|internal|user)\\:(\\w+)$" ), QRegularExpression::CaseInsensitiveOption );
QRegularExpression reCrsId( sReCrsId );
const thread_local QRegularExpression reCrsId( QStringLiteral( "^(epsg|esri|osgeo|ignf|zangi|iau2000|postgis|internal|user)\\:(\\w+)$" ), QRegularExpression::CaseInsensitiveOption );
QRegularExpressionMatch match = reCrsId.match( definition );
if ( match.capturedStart() == 0 )
{
Expand Down Expand Up @@ -319,8 +318,7 @@ bool QgsCoordinateReferenceSystem::createFromString( const QString &definition )
}
else
{
const static QRegularExpression sReCrsStr( "^(?:(wkt|proj4|proj)\\:)?(.+)$", QRegularExpression::CaseInsensitiveOption );
QRegularExpression reCrsStr( sReCrsStr );
const thread_local QRegularExpression reCrsStr( "^(?:(wkt|proj4|proj)\\:)?(.+)$", QRegularExpression::CaseInsensitiveOption );
match = reCrsStr.match( definition );
if ( match.capturedStart() == 0 )
{
Expand Down Expand Up @@ -409,24 +407,21 @@ bool QgsCoordinateReferenceSystem::createFromOgcWmsCrs( const QString &crs )

QString wmsCrs = crs;

static const QRegularExpression sReUri( QStringLiteral( "http://www\\.opengis\\.net/def/crs/([^/]+).+/([^/]+)" ), QRegularExpression::CaseInsensitiveOption );
QRegularExpression reUri( sReUri );
thread_local const QRegularExpression reUri( QStringLiteral( "http://www\\.opengis\\.net/def/crs/([^/]+).+/([^/]+)" ), QRegularExpression::CaseInsensitiveOption );
QRegularExpressionMatch re_uri_match = reUri.match( wmsCrs );
if ( re_uri_match.hasMatch() )
{
wmsCrs = re_uri_match.captured( 1 ) + ':' + re_uri_match.captured( 2 );
}
else
{
static const QRegularExpression sReUrn( QStringLiteral( "urn:ogc:def:crs:([^:]+).+([^:]+)" ), QRegularExpression::CaseInsensitiveOption );
QRegularExpression reUrn( sReUrn );
thread_local const QRegularExpression reUrn( QStringLiteral( "urn:ogc:def:crs:([^:]+).+([^:]+)" ), QRegularExpression::CaseInsensitiveOption );
QRegularExpressionMatch re_urn_match = reUrn.match( wmsCrs );
if ( re_urn_match.hasMatch() )
wmsCrs = re_urn_match.captured( 1 ) + ':' + re_urn_match.captured( 2 );
else
{
static const QRegularExpression sReUrnCustom( QStringLiteral( "(user|custom|qgis):(\\d+)" ), QRegularExpression::CaseInsensitiveOption );
QRegularExpression reUrnCustom( sReUrnCustom );
thread_local const QRegularExpression reUrnCustom( QStringLiteral( "(user|custom|qgis):(\\d+)" ), QRegularExpression::CaseInsensitiveOption );
QRegularExpressionMatch re_urn_custom_match = reUrnCustom.match( wmsCrs );
if ( re_urn_custom_match.hasMatch() && createFromSrsId( re_urn_custom_match.captured( 2 ).toInt() ) )
{
Expand Down Expand Up @@ -1040,7 +1035,7 @@ bool QgsCoordinateReferenceSystem::createFromProj( const QString &projString, co
Q_UNUSED( identify )

QRegExp projRegExp( QStringLiteral( "\\+proj=(\\S+)" ) );
int myStart = myProjRegExp.indexIn( myProj4String );
int myStart = projRegExp.indexIn( myProj4String );
if ( myStart == -1 )
{
locker.changeMode( QgsReadWriteLocker::Write );
Expand All @@ -1050,7 +1045,7 @@ bool QgsCoordinateReferenceSystem::createFromProj( const QString &projString, co
return d->mIsValid;
}

d->mProjectionAcronym = myProjRegExp.cap( 1 );
d->mProjectionAcronym = projRegExp.cap( 1 );

QRegExp myEllipseRegExp( QStringLiteral( "\\+ellps=(\\S+)" ) );
myStart = myEllipseRegExp.indexIn( myProj4String );
Expand Down Expand Up @@ -1127,8 +1122,7 @@ bool QgsCoordinateReferenceSystem::createFromProj( const QString &projString, co
// also with parameters containing spaces (e.g. +nadgrids)
// make sure result is trimmed (#5598)
QStringList myParams;
static const QRegularExpression sRegExp( "\\s+(?=\\+)" );
QRegularExpression regExp( sRegExp );
thread_local const QRegularExpression regExp( "\\s+(?=\\+)" );
{
const auto constSplit = myProj4String.split( regExp, QString::SkipEmptyParts );
for ( const QString &param : constSplit )
Expand Down Expand Up @@ -2449,8 +2443,7 @@ bool testIsGeographic( PJ *crs )

void getOperationAndEllipsoidFromProjString( const QString &proj, QString &operation, QString &ellipsoid )
{
static const QRegularExpression sProjRegExp( QStringLiteral( "\\+proj=(\\S+)" ) );
QRegularExpression projRegExp( sProjRegExp );
thread_local const QRegularExpression projRegExp( QStringLiteral( "\\+proj=(\\S+)" ) );
const QRegularExpressionMatch projMatch = projRegExp.match( proj );
if ( !projMatch.hasMatch() )
{
Expand All @@ -2459,8 +2452,7 @@ void getOperationAndEllipsoidFromProjString( const QString &proj, QString &opera
}
operation = projMatch.captured( 1 );

static const QRegularExpression sEllipseRegExp( QStringLiteral( "\\+(?:ellps|datum)=(\\S+)" ) );
QRegularExpression ellipseRegExp( sEllipseRegExp );
thread_local const QRegularExpression ellipseRegExp( QStringLiteral( "\\+(?:ellps|datum)=(\\S+)" ) );
const QRegularExpressionMatch ellipseMatch = projRegExp.match( proj );
QString ellps;
if ( !ellipseMatch.hasMatch() )
Expand Down
3 changes: 1 addition & 2 deletions src/core/qgsprojutils.cpp
Expand Up @@ -256,8 +256,7 @@ bool QgsProjUtils::coordinateOperationIsAvailable( const QString &projDef )

QList<QgsDatumTransform::GridDetails> QgsProjUtils::gridsUsed( const QString &proj )
{
static QRegularExpression sRegex( QStringLiteral( "\\+(?:nad)?grids=(.*?)\\s" ) );
QRegularExpression regex( sRegex );
const thread_local QRegularExpression regex( QStringLiteral( "\\+(?:nad)?grids=(.*?)\\s" ) );

QList< QgsDatumTransform::GridDetails > grids;
QRegularExpressionMatchIterator matches = regex.globalMatch( proj );
Expand Down

0 comments on commit e32b1fc

Please sign in to comment.