diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-10 20:17:54 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-11 14:45:38 +0200 |
commit | 85c2ed8dc790689ce69ff0a08ff5a4de98df54b7 (patch) | |
tree | f7d7f6fce51d1a4443608971da7d9c42b1201fa3 /desktop | |
parent | 117688bd3f51a7a50b2620aa7dcc0c065f29d402 (diff) |
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 7 | ||||
-rw-r--r-- | desktop/source/splash/splash.cxx | 27 |
2 files changed, 18 insertions, 16 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 1d36f54f3ffc..1aff45ab0cde 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -55,6 +55,7 @@ #include <config_mpl.h> #include <tools/json_writer.hxx> #include <o3tl/unit_conversion.hxx> +#include <o3tl/string_view.hxx> #include <lib/init.hxx> #include <svx/svxids.hrc> @@ -860,7 +861,7 @@ void DesktopLOKTest::testRowColumnHeaders() bool bNotEnoughHeaders = true; for (const boost::property_tree::ptree::value_type& rValue : aTree.get_child("rows")) { - sal_Int32 nSize = OString(rValue.second.get<std::string>("size").c_str()).toInt32(); + sal_Int32 nSize = o3tl::toInt32(rValue.second.get<std::string>("size")); nSize = o3tl::convert(nSize, o3tl::Length::px, o3tl::Length::twip); OString aText(rValue.second.get<std::string>("text").c_str()); @@ -889,7 +890,7 @@ void DesktopLOKTest::testRowColumnHeaders() bNotEnoughHeaders = true; for (const boost::property_tree::ptree::value_type& rValue : aTree.get_child("columns")) { - sal_Int32 nSize = OString(rValue.second.get<std::string>("size").c_str()).toInt32(); + sal_Int32 nSize = o3tl::toInt32(rValue.second.get<std::string>("size")); nSize = o3tl::convert(nSize, o3tl::Length::px, o3tl::Length::twip); OString aText(rValue.second.get<std::string>("text").c_str()); if (bFirstHeader) @@ -939,7 +940,7 @@ void DesktopLOKTest::testHiddenRowHeaders() sal_Int32 nIndex = 0; for (const boost::property_tree::ptree::value_type& rValue : aTree.get_child("rows")) { - sal_Int32 nSize = OString(rValue.second.get<std::string>("size").c_str()).toInt32(); + sal_Int32 nSize = o3tl::toInt32(rValue.second.get<std::string>("size")); if (nIndex++ == 2) { diff --git a/desktop/source/splash/splash.cxx b/desktop/source/splash/splash.cxx index 6402d9f7e99b..7875d29829f8 100644 --- a/desktop/source/splash/splash.cxx +++ b/desktop/source/splash/splash.cxx @@ -33,6 +33,7 @@ #include <rtl/math.hxx> #include <vcl/introwin.hxx> #include <vcl/virdev.hxx> +#include <o3tl/string_view.hxx> #include <mutex> @@ -368,16 +369,16 @@ void SplashScreen::loadConfig() { sal_uInt8 nRed = 0; sal_Int32 idx = 0; - sal_Int32 temp = sProgressFrameColor.getToken( 0, ',', idx ).toInt32(); + sal_Int32 temp = o3tl::toInt32(o3tl::getToken(sProgressFrameColor, 0, ',', idx )); if ( idx != -1 ) { nRed = static_cast< sal_uInt8 >( temp ); - temp = sProgressFrameColor.getToken( 0, ',', idx ).toInt32(); + temp = o3tl::toInt32(o3tl::getToken(sProgressFrameColor, 0, ',', idx )); } if ( idx != -1 ) { sal_uInt8 nGreen = static_cast< sal_uInt8 >( temp ); - sal_uInt8 nBlue = static_cast< sal_uInt8 >( sProgressFrameColor.getToken( 0, ',', idx ).toInt32() ); + sal_uInt8 nBlue = static_cast< sal_uInt8 >( o3tl::toInt32(o3tl::getToken(sProgressFrameColor, 0, ',', idx )) ); _cProgressFrameColor = Color( nRed, nGreen, nBlue ); } } @@ -386,16 +387,16 @@ void SplashScreen::loadConfig() { sal_uInt8 nRed = 0; sal_Int32 idx = 0; - sal_Int32 temp = sProgressBarColor.getToken( 0, ',', idx ).toInt32(); + sal_Int32 temp = o3tl::toInt32(o3tl::getToken(sProgressBarColor, 0, ',', idx )); if ( idx != -1 ) { nRed = static_cast< sal_uInt8 >( temp ); - temp = sProgressBarColor.getToken( 0, ',', idx ).toInt32(); + temp = o3tl::toInt32(o3tl::getToken(sProgressBarColor, 0, ',', idx )); } if ( idx != -1 ) { sal_uInt8 nGreen = static_cast< sal_uInt8 >( temp ); - sal_uInt8 nBlue = static_cast< sal_uInt8 >( sProgressBarColor.getToken( 0, ',', idx ).toInt32() ); + sal_uInt8 nBlue = static_cast< sal_uInt8 >( o3tl::toInt32(o3tl::getToken(sProgressBarColor, 0, ',', idx )) ); _cProgressBarColor = Color( nRed, nGreen, nBlue ); } } @@ -404,16 +405,16 @@ void SplashScreen::loadConfig() { sal_uInt8 nRed = 0; sal_Int32 idx = 0; - sal_Int32 temp = sProgressTextColor.getToken( 0, ',', idx ).toInt32(); + sal_Int32 temp = o3tl::toInt32(o3tl::getToken(sProgressTextColor, 0, ',', idx )); if ( idx != -1 ) { nRed = static_cast< sal_uInt8 >( temp ); - temp = sProgressTextColor.getToken( 0, ',', idx ).toInt32(); + temp = o3tl::toInt32(o3tl::getToken(sProgressTextColor, 0, ',', idx )); } if ( idx != -1 ) { sal_uInt8 nGreen = static_cast< sal_uInt8 >( temp ); - sal_uInt8 nBlue = static_cast< sal_uInt8 >( sProgressTextColor.getToken( 0, ',', idx ).toInt32() ); + sal_uInt8 nBlue = static_cast< sal_uInt8 >( o3tl::toInt32(o3tl::getToken(sProgressTextColor, 0, ',', idx )) ); _cProgressTextColor = Color( nRed, nGreen, nBlue ); } } @@ -431,11 +432,11 @@ void SplashScreen::loadConfig() if ( !sSize.isEmpty() ) { sal_Int32 idx = 0; - sal_Int32 temp = sSize.getToken( 0, ',', idx ).toInt32(); + sal_Int32 temp = o3tl::toInt32(o3tl::getToken(sSize, 0, ',', idx )); if ( idx != -1 ) { _barwidth = temp; - _barheight = sSize.getToken( 0, ',', idx ).toInt32(); + _barheight = o3tl::toInt32(o3tl::getToken(sSize, 0, ',', idx )); } } @@ -445,11 +446,11 @@ void SplashScreen::loadConfig() if ( !sPosition.isEmpty() ) { sal_Int32 idx = 0; - sal_Int32 temp = sPosition.getToken( 0, ',', idx ).toInt32(); + sal_Int32 temp = o3tl::toInt32(o3tl::getToken(sPosition, 0, ',', idx )); if ( idx != -1 ) { _tlx = temp; - _tly = sPosition.getToken( 0, ',', idx ).toInt32(); + _tly = o3tl::toInt32(o3tl::getToken(sPosition, 0, ',', idx )); } } } |