Skip to content
Permalink
Browse files

Replace toUtf8().data() by toUtf8().constData()

All your uses of toUtf8().data() actually just need a const char*
So use constData() that is semantically more correct, and documented
to be faster.

From http://doc.qt.io/qt-5/qbytearray.html#data
"For read-only access, constData() is faster because it never
causes a deep copy to occur."
  • Loading branch information
rouault authored and nyalldawson committed Oct 6, 2018
1 parent f5d2d85 commit 7e81226b51dc8c6c0595ef851e83d8b7cf2a8fd8
Showing with 100 additions and 100 deletions.
  1. +1 −1 python/core/auto_generated/expression/qgsexpression.sip.in
  2. +1 −1 python/core/auto_generated/geometry/qgscircle.sip.in
  3. +1 −1 python/core/auto_generated/geometry/qgscircularstring.sip.in
  4. +1 −1 python/core/auto_generated/geometry/qgscompoundcurve.sip.in
  5. +1 −1 python/core/auto_generated/geometry/qgscurvepolygon.sip.in
  6. +1 −1 python/core/auto_generated/geometry/qgsellipse.sip.in
  7. +1 −1 python/core/auto_generated/geometry/qgsgeometry.sip.in
  8. +1 −1 python/core/auto_generated/geometry/qgslinestring.sip.in
  9. +1 −1 python/core/auto_generated/geometry/qgsmulticurve.sip.in
  10. +1 −1 python/core/auto_generated/geometry/qgsmultilinestring.sip.in
  11. +1 −1 python/core/auto_generated/geometry/qgsmultipoint.sip.in
  12. +1 −1 python/core/auto_generated/geometry/qgsmultipolygon.sip.in
  13. +1 −1 python/core/auto_generated/geometry/qgspoint.sip.in
  14. +1 −1 python/core/auto_generated/geometry/qgspolygon.sip.in
  15. +1 −1 python/core/auto_generated/geometry/qgsrectangle.sip.in
  16. +1 −1 python/core/auto_generated/qgsfield.sip.in
  17. +1 −1 python/core/auto_generated/qgspointxy.sip.in
  18. +1 −1 src/app/qgisapp.cpp
  19. +1 −1 src/core/expression/qgsexpression.h
  20. +1 −1 src/core/geometry/qgscircle.h
  21. +1 −1 src/core/geometry/qgscircularstring.h
  22. +1 −1 src/core/geometry/qgscompoundcurve.h
  23. +1 −1 src/core/geometry/qgscurvepolygon.h
  24. +1 −1 src/core/geometry/qgsellipse.h
  25. +1 −1 src/core/geometry/qgsgeometry.h
  26. +1 −1 src/core/geometry/qgslinestring.h
  27. +1 −1 src/core/geometry/qgsmulticurve.h
  28. +1 −1 src/core/geometry/qgsmultilinestring.h
  29. +1 −1 src/core/geometry/qgsmultipoint.h
  30. +1 −1 src/core/geometry/qgsmultipolygon.h
  31. +1 −1 src/core/geometry/qgspoint.h
  32. +1 −1 src/core/geometry/qgspolygon.h
  33. +1 −1 src/core/geometry/qgsrectangle.h
  34. +3 −3 src/core/qgsapplication.cpp
  35. +1 −1 src/core/qgsfield.h
  36. +1 −1 src/core/qgspointxy.h
  37. +1 −1 src/core/qgsxmlutils.h
  38. +2 −2 src/crashhandler/main.cpp
  39. +6 −6 src/gui/qgsprojectionselectiontreewidget.cpp
  40. +1 −1 src/native/mac/qgsmacnative.mm
  41. +1 −1 src/plugins/grass/qgsgrassnewmapset.cpp
  42. +1 −1 src/plugins/grass/qgsgrassplugin.cpp
  43. +4 −4 src/plugins/grass/qtermwidget/Session.cpp
  44. +1 −1 src/providers/grass/qgis.r.in.cpp
  45. +4 −4 src/providers/grass/qgis.v.in.cpp
  46. +13 −13 src/providers/grass/qgsgrass.cpp
  47. +5 −5 src/providers/grass/qgsgrassimport.cpp
  48. +2 −2 src/providers/grass/qgsgrassprovider.cpp
  49. +3 −3 src/providers/grass/qgsgrassvector.cpp
  50. +5 −5 src/providers/grass/qgsgrassvectormap.cpp
  51. +11 −11 src/providers/oracle/qgsoracletablecache.cpp
  52. +2 −2 src/python/qgspythonutilsimpl.cpp
@@ -590,7 +590,7 @@ value. The value may be null.
SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsExpression: '%1'>" ).arg( sipCpp->expression() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

};
@@ -256,7 +256,7 @@ Returns true if the circle contains the ``point``.
SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsCircle: %1>" ).arg( sipCpp->toString() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End
};

@@ -169,7 +169,7 @@ Sets the circular string's points
SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsCircularString: %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

protected:
@@ -173,7 +173,7 @@ Appends first point if not already closed.
SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsCompoundCurve: %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

protected:
@@ -219,7 +219,7 @@ Returns approximate rotation angle for a vertex. Usually average angle between a
SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsCurvePolygon: %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

protected:
@@ -251,7 +251,7 @@ Members will be truncated to the specified precision.
SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsEllipse: %1>" ).arg( sipCpp->toString() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

protected:
@@ -1297,7 +1297,7 @@ Exports the geometry to WKT
SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsGeometry: %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

QString asJson( int precision = 17 ) const;
@@ -330,7 +330,7 @@ of the curve.
SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsLineString: %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

protected:
@@ -59,7 +59,7 @@ Returns a copy of the multi curve, where each component curve has had its line d
SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsMultiCurve: %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

};
@@ -56,7 +56,7 @@ Returns the geometry converted to the more generic curve type :py:class:`QgsMult
SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsMultiLineString: %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

protected:
@@ -58,7 +58,7 @@ Multi point geometry collection.
SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsMultiPoint: %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

protected:
@@ -57,7 +57,7 @@ Returns the geometry converted to the more generic curve type :py:class:`QgsMult
SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsMultiPolygon: %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

protected:
@@ -429,7 +429,7 @@ Angle undefined. Always returns 0.0
SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsPoint: %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

protected:
@@ -68,7 +68,7 @@ negative if the point lies outside the polygon.
SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsPolygon: %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

protected:
@@ -325,7 +325,7 @@ Converts the rectangle to a 3D box, with the specified
SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsRectangle: %1>" ).arg( sipCpp->asWktCoordinates() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

};
@@ -333,7 +333,7 @@ by manual field configuration.
SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsField: %1 (%2)>" ).arg( sipCpp->name() ).arg( sipCpp->typeName() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

}; // class QgsField
@@ -231,7 +231,7 @@ Multiply x and y by the given value
SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsPointXY: %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

int __len__();
@@ -10534,7 +10534,7 @@ void QgisApp::openURL( QString url, bool useQgisDocDirectory )
* commandline application rather than a bundled application.
*/
CFURLRef urlRef = CFURLCreateWithBytes( kCFAllocatorDefault,
reinterpret_cast<const UInt8 *>( url.toUtf8().data() ), url.length(),
reinterpret_cast<const UInt8 *>( url.toUtf8().constData() ), url.length(),
kCFStringEncodingUTF8, nullptr );
OSStatus status = LSOpenCFURLRef( urlRef, nullptr );
status = 0; //avoid compiler warning
@@ -614,7 +614,7 @@ class CORE_EXPORT QgsExpression
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QStringLiteral( "<QgsExpression: '%1'>" ).arg( sipCpp->expression() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
% End
#endif

@@ -251,7 +251,7 @@ class CORE_EXPORT QgsCircle : public QgsEllipse
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QStringLiteral( "<QgsCircle: %1>" ).arg( sipCpp->toString() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
% End
#endif
};
@@ -153,7 +153,7 @@ class CORE_EXPORT QgsCircularString: public QgsCurve
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QStringLiteral( "<QgsCircularString: %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
% End
#endif

@@ -153,7 +153,7 @@ class CORE_EXPORT QgsCompoundCurve: public QgsCurve
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QStringLiteral( "<QgsCompoundCurve: %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
% End
#endif

@@ -209,7 +209,7 @@ class CORE_EXPORT QgsCurvePolygon: public QgsSurface
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QStringLiteral( "<QgsCurvePolygon: %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
% End
#endif

@@ -244,7 +244,7 @@ class CORE_EXPORT QgsEllipse
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QStringLiteral( "<QgsEllipse: %1>" ).arg( sipCpp->toString() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
% End
#endif

@@ -1256,7 +1256,7 @@ class CORE_EXPORT QgsGeometry
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QStringLiteral( "<QgsGeometry: %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
% End
#endif

@@ -360,7 +360,7 @@ class CORE_EXPORT QgsLineString: public QgsCurve
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QStringLiteral( "<QgsLineString: %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
% End
#endif

@@ -77,7 +77,7 @@ class CORE_EXPORT QgsMultiCurve: public QgsGeometryCollection
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QStringLiteral( "<QgsMultiCurve: %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
% End
#endif

@@ -69,7 +69,7 @@ class CORE_EXPORT QgsMultiLineString: public QgsMultiCurve
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QStringLiteral( "<QgsMultiLineString: %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
% End
#endif

@@ -70,7 +70,7 @@ class CORE_EXPORT QgsMultiPoint: public QgsGeometryCollection
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QStringLiteral( "<QgsMultiPoint: %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
% End
#endif

@@ -69,7 +69,7 @@ class CORE_EXPORT QgsMultiPolygon: public QgsMultiSurface
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QStringLiteral( "<QgsMultiPolygon: %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
% End
#endif

@@ -500,7 +500,7 @@ class CORE_EXPORT QgsPoint: public QgsAbstractGeometry
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QStringLiteral( "<QgsPoint: %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
% End
#endif

@@ -88,7 +88,7 @@ class CORE_EXPORT QgsPolygon: public QgsCurvePolygon
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QStringLiteral( "<QgsPolygon: %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
% End
#endif

@@ -545,7 +545,7 @@ class CORE_EXPORT QgsRectangle
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QStringLiteral( "<QgsRectangle: %1>" ).arg( sipCpp->asWktCoordinates() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
% End
#endif

@@ -666,11 +666,11 @@ QString QgsApplication::resolvePkgPath()
ABISYM( mBuildSourcePath ) = f.readLine().trimmed();
ABISYM( mBuildOutputPath ) = f.readLine().trimmed();
QgsDebugMsgLevel( QStringLiteral( "Running from build directory!" ), 4 );
QgsDebugMsgLevel( QStringLiteral( "- source directory: %1" ).arg( ABISYM( mBuildSourcePath ).toUtf8().data() ), 4 );
QgsDebugMsgLevel( QStringLiteral( "- output directory of the build: %1" ).arg( ABISYM( mBuildOutputPath ).toUtf8().data() ), 4 );
QgsDebugMsgLevel( QStringLiteral( "- source directory: %1" ).arg( ABISYM( mBuildSourcePath ).toUtf8().constData() ), 4 );
QgsDebugMsgLevel( QStringLiteral( "- output directory of the build: %1" ).arg( ABISYM( mBuildOutputPath ).toUtf8().constData() ), 4 );
#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
ABISYM( mCfgIntDir ) = appPath.split( '/', QString::SkipEmptyParts ).last();
qDebug( "- cfg: %s", ABISYM( mCfgIntDir ).toUtf8().data() );
qDebug( "- cfg: %s", ABISYM( mCfgIntDir ).toUtf8().constData() );
#endif
}
}
@@ -339,7 +339,7 @@ class CORE_EXPORT QgsField
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QStringLiteral( "<QgsField: %1 (%2)>" ).arg( sipCpp->name() ).arg( sipCpp->typeName() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
% End
#endif

@@ -298,7 +298,7 @@ class CORE_EXPORT QgsPointXY
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QStringLiteral( "<QgsPointXY: %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
% End

int __len__();
@@ -97,7 +97,7 @@ class CORE_EXPORT QgsXmlUtils
if ( metaEnum.isValid() )
{
bool ok = false;
int newValue = metaEnum.keysToValue( sourceCategoriesStr.toUtf8().data(), &ok );
int newValue = metaEnum.keysToValue( sourceCategoriesStr.toUtf8().constData(), &ok );
if ( ok )
value = static_cast<T>( newValue );
}
@@ -42,7 +42,7 @@ int main( int argc, char *argv[] )
QCoreApplication::setApplicationName( "QGIS3" );

QString extraInfoFile = QString( argv[1] );
std::cout << "Extra Info File: " << extraInfoFile.toUtf8().data() << std::endl;
std::cout << "Extra Info File: " << extraInfoFile.toUtf8().constData() << std::endl;

QFile file( extraInfoFile );
QString processIdString;
@@ -75,7 +75,7 @@ int main( int argc, char *argv[] )
std::cout << "Process ID: " << processIdString.toLocal8Bit().constData() << std::endl;
std::cout << "Thread ID:" << threadIdString.toLocal8Bit().constData() << std::endl;
std::cout << "Exception Pointer: " << exceptionPointersString.toLocal8Bit().constData() << std::endl;
std::cout << "Symbol Path :" << symbolPaths.toUtf8().data() << std::endl;
std::cout << "Symbol Path :" << symbolPaths.toUtf8().constData() << std::endl;

std::unique_ptr<QgsStackTrace> stackTrace( QgsStackTrace::trace( processId, threadId, exception, symbolPaths ) );

0 comments on commit 7e81226

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