diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-04-12 10:50:46 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-04-14 07:54:28 +0200 |
commit | bc2101646bc6e63944c42500af5a15134b9b2d17 (patch) | |
tree | ca1da50da2e3e76eef650a1ae3956c16e0a19f33 /framework | |
parent | ad97694737c99889bc0eb21efccb83768d510361 (diff) |
loplugin:stringviewparam improvements
improve the check by checking for methods that exclude
using string_view, rather than checking for methods that
__can__ use string_view, which leads to exposing
some holes in our o3tl/string_view.hxx coverage.
Change-Id: Ic9dd60441c671f502692f9cd2a1bb67301c4b960
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150277
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'framework')
-rw-r--r-- | framework/inc/jobs/joburl.hxx | 2 | ||||
-rw-r--r-- | framework/source/jobs/joburl.cxx | 17 |
2 files changed, 10 insertions, 9 deletions
diff --git a/framework/inc/jobs/joburl.hxx b/framework/inc/jobs/joburl.hxx index 3a227a375c78..23486ec2f4d9 100644 --- a/framework/inc/jobs/joburl.hxx +++ b/framework/inc/jobs/joburl.hxx @@ -96,7 +96,7 @@ class JobURL private: - static bool implst_split( const OUString& sPart , + static bool implst_split( std::u16string_view sPart , const char* pPartIdentifier , sal_Int32 nPartLength , OUString& rPartValue , diff --git a/framework/source/jobs/joburl.cxx b/framework/source/jobs/joburl.cxx index fc1424867d99..5533014edf80 100644 --- a/framework/source/jobs/joburl.cxx +++ b/framework/source/jobs/joburl.cxx @@ -24,6 +24,7 @@ #include <jobs/joburl.hxx> #include <vcl/svapp.hxx> +#include <o3tl/string_view.hxx> namespace framework{ @@ -205,14 +206,14 @@ bool JobURL::getService( /*OUT*/ OUString& sService ) const @return <TRUE/> if the identifier could be found and the string was split. <FALSE/> otherwise. */ -bool JobURL::implst_split( /*IN*/ const OUString& sPart , +bool JobURL::implst_split( /*IN*/ std::u16string_view sPart , /*IN*/ const char* pPartIdentifier , /*IN*/ sal_Int32 nPartLength , /*OUT*/ OUString& rPartValue , /*OUT*/ OUString& rPartArguments ) { // first search for the given identifier - bool bPartFound = sPart.matchIgnoreAsciiCaseAsciiL(pPartIdentifier,nPartLength); + bool bPartFound = o3tl::matchIgnoreAsciiCase(sPart, std::string_view(pPartIdentifier,nPartLength)); // If it exist - we can split the part and return sal_True. // Otherwise we do nothing and return sal_False. @@ -222,16 +223,16 @@ bool JobURL::implst_split( /*IN*/ const OUString& sPart , // Do so - we set the return value with the whole part string. // Arguments will be set to an empty string as default. // If we detect the right sign - we split the arguments and overwrite the default. - OUString sValueAndArguments = sPart.copy(nPartLength); - OUString sValue = sValueAndArguments; + std::u16string_view sValueAndArguments = sPart.substr(nPartLength); + std::u16string_view sValue = sValueAndArguments; OUString sArguments; - sal_Int32 nArgStart = sValueAndArguments.indexOf('?'); - if (nArgStart!=-1) + size_t nArgStart = sValueAndArguments.find('?'); + if (nArgStart != std::u16string_view::npos) { - sValue = sValueAndArguments.copy(0,nArgStart); + sValue = sValueAndArguments.substr(0,nArgStart); ++nArgStart; // ignore '?'! - sArguments = sValueAndArguments.copy(nArgStart); + sArguments = sValueAndArguments.substr(nArgStart); } rPartValue = sValue; |