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 /xmloff/source/meta/xmlversion.cxx | |
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 'xmloff/source/meta/xmlversion.cxx')
-rw-r--r-- | xmloff/source/meta/xmlversion.cxx | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/xmloff/source/meta/xmlversion.cxx b/xmloff/source/meta/xmlversion.cxx index 2b332e2afe9d..47acf7737be6 100644 --- a/xmloff/source/meta/xmlversion.cxx +++ b/xmloff/source/meta/xmlversion.cxx @@ -23,6 +23,7 @@ #include <xmloff/xmlmetae.hxx> #include <osl/diagnose.h> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> #include <xmloff/xmltoken.hxx> #include <comphelper/processfactory.hxx> @@ -236,17 +237,17 @@ bool XMLVersionContext::ParseISODateTimeString( else { sal_Int32 n = 0; - nYear = aDateStr.getToken( 0, '-', n ).toInt32(); + nYear = o3tl::toInt32(o3tl::getToken(aDateStr, 0, '-', n )); if ( nYear > 9999 ) bSuccess = false; else if ( nDateTokens >= 2 ) { - nMonth = aDateStr.getToken( 0, '-', n ).toInt32(); + nMonth = o3tl::toInt32(o3tl::getToken(aDateStr, 0, '-', n )); if ( nMonth > 12 ) bSuccess = false; else if ( nDateTokens >= 3 ) { - nDay = aDateStr.getToken( 0, '-', n ).toInt32(); + nDay = o3tl::toInt32(o3tl::getToken(aDateStr, 0, '-', n )); if ( nDay > 31 ) bSuccess = false; } @@ -268,17 +269,17 @@ bool XMLVersionContext::ParseISODateTimeString( else { sal_Int32 n = 0; - nHour = aTimeStr.getToken( 0, ':', n ).toInt32(); + nHour = o3tl::toInt32(o3tl::getToken(aTimeStr, 0, ':', n )); if ( nHour > 23 ) bSuccess = false; else if ( nTimeTokens >= 2 ) { - nMin = aTimeStr.getToken( 0, ':', n ).toInt32(); + nMin = o3tl::toInt32(o3tl::getToken(aTimeStr, 0, ':', n )); if ( nMin > 59 ) bSuccess = false; else if ( nTimeTokens >= 3 ) { - nSec = aTimeStr.getToken( 0, ':', n ).toInt32(); + nSec = o3tl::toInt32(o3tl::getToken(aTimeStr, 0, ':', n )); if ( nSec > 59 ) bSuccess = false; } |