@@ -277,10 +277,12 @@ QgsGmlStreamingParser::QgsGmlStreamingParser( const QString& typeName,
277
277
: mTypeName( typeName )
278
278
, mTypeNameBA( mTypeName .toUtf8() )
279
279
, mTypeNamePtr( mTypeNameBA .constData() )
280
+ , mTypeNameUTF8Len( strlen( mTypeNamePtr ) )
280
281
, mWkbType( QgsWkbTypes::Unknown )
281
282
, mGeometryAttribute( geometryAttribute )
282
283
, mGeometryAttributeBA( geometryAttribute.toUtf8() )
283
284
, mGeometryAttributePtr( mGeometryAttributeBA .constData() )
285
+ , mGeometryAttributeUTF8Len( strlen( mGeometryAttributePtr ) )
284
286
, mFields( fields )
285
287
, mIsException( false )
286
288
, mTruncatedResponse( false )
@@ -315,6 +317,7 @@ QgsGmlStreamingParser::QgsGmlStreamingParser( const QString& typeName,
315
317
mTypeName = mTypeName .mid ( index + 1 );
316
318
mTypeNameBA = mTypeName .toUtf8 ();
317
319
mTypeNamePtr = mTypeNameBA .constData ();
320
+ mTypeNameUTF8Len = strlen ( mTypeNamePtr );
318
321
}
319
322
320
323
mParser = XML_ParserCreateNS ( nullptr , NS_SEPARATOR );
@@ -340,8 +343,10 @@ QgsGmlStreamingParser::QgsGmlStreamingParser( const QList<LayerProperties>& laye
340
343
bool invertAxisOrientation )
341
344
: mLayerProperties( layerProperties )
342
345
, mTypeNamePtr( nullptr )
346
+ , mTypeNameUTF8Len( 0 )
343
347
, mWkbType( QgsWkbTypes::Unknown )
344
348
, mGeometryAttributePtr( nullptr )
349
+ , mGeometryAttributeUTF8Len( 0 )
345
350
, mFields( fields )
346
351
, mIsException( false )
347
352
, mTruncatedResponse( false )
@@ -397,13 +402,15 @@ QgsGmlStreamingParser::QgsGmlStreamingParser( const QList<LayerProperties>& laye
397
402
mGeometryAttribute = mLayerProperties [0 ].mGeometryAttribute ;
398
403
mGeometryAttributeBA = mGeometryAttribute .toUtf8 ();
399
404
mGeometryAttributePtr = mGeometryAttributeBA .constData ();
405
+ mGeometryAttributeUTF8Len = strlen ( mGeometryAttributePtr );
400
406
int index = mTypeName .indexOf ( ' :' );
401
407
if ( index != -1 && index < mTypeName .length () )
402
408
{
403
409
mTypeName = mTypeName .mid ( index + 1 );
404
410
}
405
411
mTypeNameBA = mTypeName .toUtf8 ();
406
412
mTypeNamePtr = mTypeNameBA .constData ();
413
+ mTypeNameUTF8Len = strlen ( mTypeNamePtr );
407
414
}
408
415
409
416
mEndian = QgsApplication::endian ();
@@ -542,7 +549,7 @@ void QgsGmlStreamingParser::startElement( const XML_Char* el, const XML_Char** a
542
549
}
543
550
}
544
551
}
545
- else if ( localNameLen == mGeometryAttribute . size ( ) &&
552
+ else if ( localNameLen == static_cast < int >( mGeometryAttributeUTF8Len ) &&
546
553
memcmp ( pszLocalName, mGeometryAttributePtr , localNameLen ) == 0 )
547
554
{
548
555
mParseModeStack .push ( QgsGmlStreamingParser::Geometry );
@@ -606,6 +613,7 @@ void QgsGmlStreamingParser::startElement( const XML_Char* el, const XML_Char** a
606
613
}
607
614
mGeometryAttributeBA = mGeometryAttribute .toUtf8 ();
608
615
mGeometryAttributePtr = mGeometryAttributeBA .constData ();
616
+ mGeometryAttributeUTF8Len = strlen ( mGeometryAttributePtr );
609
617
mParseModeStack .push ( QgsGmlStreamingParser::FeatureTuple );
610
618
QString id;
611
619
if ( mGMLNameSpaceURI .isEmpty () )
@@ -634,7 +642,8 @@ void QgsGmlStreamingParser::startElement( const XML_Char* el, const XML_Char** a
634
642
}
635
643
}
636
644
else if ( theParseMode == None &&
637
- localNameLen == mTypeName .size () && memcmp ( pszLocalName, mTypeNamePtr , mTypeName .size () ) == 0 )
645
+ localNameLen == static_cast <int >( mTypeNameUTF8Len ) &&
646
+ memcmp ( pszLocalName, mTypeNamePtr , mTypeNameUTF8Len ) == 0 )
638
647
{
639
648
Q_ASSERT ( !mCurrentFeature );
640
649
mCurrentFeature = new QgsFeature ( mFeatureCount );
@@ -857,7 +866,8 @@ void QgsGmlStreamingParser::endElement( const XML_Char* el )
857
866
858
867
setAttribute ( mAttributeName , mStringCash );
859
868
}
860
- else if ( theParseMode == Geometry && localNameLen == mGeometryAttribute .size () &&
869
+ else if ( theParseMode == Geometry &&
870
+ localNameLen == static_cast <int >( mGeometryAttributeUTF8Len ) &&
861
871
memcmp ( pszLocalName, mGeometryAttributePtr , localNameLen ) == 0 )
862
872
{
863
873
mParseModeStack .pop ();
@@ -935,8 +945,9 @@ void QgsGmlStreamingParser::endElement( const XML_Char* el )
935
945
}
936
946
else if (( theParseMode == Tuple && !mTypeNamePtr &&
937
947
LOCALNAME_EQUALS ( " Tuple" ) ) ||
938
- ( theParseMode == Feature && localNameLen == mTypeName .size () &&
939
- memcmp ( pszLocalName, mTypeNamePtr , mTypeName .size () ) == 0 ) )
948
+ ( theParseMode == Feature &&
949
+ localNameLen == static_cast <int >( mTypeNameUTF8Len ) &&
950
+ memcmp ( pszLocalName, mTypeNamePtr , mTypeNameUTF8Len ) == 0 ) )
940
951
{
941
952
Q_ASSERT ( mCurrentFeature );
942
953
if ( !mCurrentFeature ->hasGeometry () )
0 commit comments