Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[postgres] Speed up array parsing (fixes #33226) (#33227)
(cherry picked from commit ac958de)
  • Loading branch information
Hugo Mercier authored and nyalldawson committed Dec 16, 2019
1 parent 8ad1352 commit e156b03
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -4389,11 +4389,10 @@ static void jumpSpace( const QString &txt, int &i )
QString QgsPostgresProvider::getNextString( const QString &txt, int &i, const QString &sep )
{
jumpSpace( txt, i );
QString cur = txt.mid( i );
if ( cur.startsWith( '"' ) )
if ( i < txt.length() && txt.at( i ) == '"' )
{
QRegExp stringRe( "^\"((?:\\\\.|[^\"\\\\])*)\".*" );
if ( !stringRe.exactMatch( cur ) )
if ( !stringRe.exactMatch( txt.mid( i ) ) )
{
QgsMessageLog::logMessage( tr( "Cannot find end of double quoted string: %1" ).arg( txt ), tr( "PostGIS" ) );
return QString();
Expand All @@ -4410,14 +4409,17 @@ QString QgsPostgresProvider::getNextString( const QString &txt, int &i, const QS
}
else
{
int sepPos = cur.indexOf( sep );
if ( sepPos < 0 )
int start = i;
for ( ; i < txt.length(); i++ )
{
i += cur.length();
return cur.trimmed();
if ( txt.midRef( i ).startsWith( sep ) )
{
QStringRef r( txt.midRef( start, i - start ) );
i += sep.length();
return r.trimmed().toString();
}
}
i += sepPos + sep.length();
return cur.left( sepPos ).trimmed();
return txt.midRef( start, i - start ).trimmed().toString();
}
}

Expand Down

0 comments on commit e156b03

Please sign in to comment.