From 85c2ed8dc790689ce69ff0a08ff5a4de98df54b7 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sun, 10 Apr 2022 20:17:54 +0200 Subject: loplugin:stringview add check for getToken().toInt32 where we can convert that to o3tl::toInt32(o3tl::getToken( and avoid the heap allocation of a temporary string Change-Id: Ib11c19c6e6cdc0de3e551affd3578d181e292de4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132810 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sdext/source/minimizer/optimizerdialogcontrols.cxx | 3 ++- sdext/source/pdfimport/test/pdfunzip.cxx | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'sdext') diff --git a/sdext/source/minimizer/optimizerdialogcontrols.cxx b/sdext/source/minimizer/optimizerdialogcontrols.cxx index 8b98f2a5faaf..92ecf16e09e1 100644 --- a/sdext/source/minimizer/optimizerdialogcontrols.cxx +++ b/sdext/source/minimizer/optimizerdialogcontrols.cxx @@ -35,6 +35,7 @@ #include #include #include +#include using namespace ::com::sun::star::awt; using namespace ::com::sun::star::uno; @@ -480,7 +481,7 @@ namespace bool lcl_getResolutionText(OUString& rResolutionText, const OUString& rImageResolution, sal_Int32 nTargetRes) { sal_Int32 nIdx{ 0 }; - if (rImageResolution.getToken(0, ';', nIdx).toInt32()!=nTargetRes) + if (o3tl::toInt32(o3tl::getToken(rImageResolution, 0, ';', nIdx))!=nTargetRes) return false; rResolutionText = rImageResolution.getToken(0, ';', nIdx); return true; diff --git a/sdext/source/pdfimport/test/pdfunzip.cxx b/sdext/source/pdfimport/test/pdfunzip.cxx index 3e2e614a9327..86797056e841 100644 --- a/sdext/source/pdfimport/test/pdfunzip.cxx +++ b/sdext/source/pdfimport/test/pdfunzip.cxx @@ -27,6 +27,7 @@ #include #include #include +#include #include @@ -478,9 +479,9 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv ) sal_Int32 nObject = 0; sal_Int32 nGeneration = 0; sal_Int32 nGenIndex = 0; - nObject = aToken.getToken( 0, ':', nGenIndex ).toInt32(); + nObject = o3tl::toInt32( o3tl::getToken( aToken, 0, ':', nGenIndex ) ); if( nGenIndex != -1 ) - nGeneration = aToken.getToken( 0, ':', nGenIndex ).toInt32(); + nGeneration = o3tl::toInt32( o3tl::getToken(aToken, 0, ':', nGenIndex )); s_aEmitObjects.push_back( std::pair(nObject,nGeneration) ); } } -- cgit