Skip to content
Permalink
Browse files

thread_local

  • Loading branch information
m-kuhn committed Dec 23, 2020
1 parent 6f349eb commit 67c24fa239d4e07ecdc53491380b1c8cd7d229f6
@@ -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 );
}
@@ -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 );
}

@@ -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() )
{
@@ -878,7 +878,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() )
{
@@ -1095,7 +1095,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;
}

@@ -288,8 +288,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 )
{
@@ -317,8 +316,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 )
{
@@ -407,24 +405,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() ) )
{
@@ -1038,7 +1033,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 );
@@ -1048,7 +1043,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 );
@@ -1125,8 +1120,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 )
@@ -2447,8 +2441,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() )
{
@@ -2457,8 +2450,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() )
@@ -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 );

0 comments on commit 67c24fa

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