Skip to content

Commit

Permalink
More thread_local QRegularExpression
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 28, 2021
1 parent 8aec877 commit af4c447
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/gui/qgstemporalcontrollerwidget.cpp
Expand Up @@ -604,8 +604,14 @@ void QgsTemporalControllerWidget::setTimeStep( const QgsInterval &timeStep )
QgsUnitTypes::TemporalUnit unit = static_cast<QgsUnitTypes::TemporalUnit>( mTimeStepsComboBox->itemData( i ).toInt() );
double value = timeStep.seconds() * QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::TemporalSeconds, unit );
QString string = QString::number( value, 'f', precision );
string.remove( QRegularExpression( "0+$" ) ); //remove trailing zero
string.remove( QRegularExpression( "[.]+$" ) ); //remove last point if present

const thread_local QRegularExpression trailingZeroRegEx = QRegularExpression( QStringLiteral( "0+$" ) );
//remove trailing zero
string.remove( trailingZeroRegEx );

const thread_local QRegularExpression trailingPointRegEx = QRegularExpression( QStringLiteral( "[.]+$" ) );
//remove last point if present
string.remove( trailingPointRegEx );

if ( value >= 1
&& string.size() <= stringSize // less significant digit than currently selected
Expand Down

0 comments on commit af4c447

Please sign in to comment.