diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2021-10-01 09:09:45 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2021-10-11 14:22:22 +0200 |
commit | 4f5b3e4bd53d6d61df1f65f496f7bc8dc525c8a1 (patch) | |
tree | e0ac44b8f22f944f3303bac8e494da41d6c7b164 /desktop | |
parent | 5f84c44e3d5ff19b800b6358e61228546e318d4f (diff) |
In O[U]StringBuffer, make string_view params replacements for OUString ones
...for LIBO_INTERNAL_ONLY, instead of having them as additional overloads. That
way, loplugin:bufferadd and loplugin:stringviewparam found many further
opportunities for simplification (all addressed here). Some notes:
* There is no longer an implicit conversion from O[U]String to O[U]StringBuffer
(as that goes via user-defined conversions through string_view now), which was
most noticeable in copy initializations like
OStringBuffer buf = someStr;
that had to be changed to direct initialization,
OStringBuffer buf(someStr);
But then again, it wasn't too many places that were affected and I think we can
live with that.
* I made the O[U]StringBuffer ctors taking string_view non-explicit, mainly to
get them in line with their counterparts taking O[U]String.
* I added an OUStringBuffer::lastIndexOf string_view overload that was missing
(relative to OUStringBuffer::indexOf).
* loplugin:stringconstant needed some addition to keep the
compilerplugins/clang/test/stringconstant.cxx checks related to
OStringBuffer::append and OStringBuffer::insert working.
* loplugin:stringviewparam no longer needs the special O[U]StringBuffer-related
code that had been introduced in 1250aecd71fabde4dba990bfceb61bbe8e06b8ea
"loplugin:stringviewparam extend to new.."
Change-Id: Ib1bb8c4632d99b744e742605a9fef6eae959fd72
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122904
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/deployment/misc/dp_platform.cxx | 7 | ||||
-rw-r--r-- | desktop/source/deployment/registry/component/dp_component.cxx | 12 | ||||
-rw-r--r-- | desktop/source/deployment/registry/dp_registry.cxx | 15 |
3 files changed, 12 insertions, 22 deletions
diff --git a/desktop/source/deployment/misc/dp_platform.cxx b/desktop/source/deployment/misc/dp_platform.cxx index 36c5486a7b40..79fb78c0b9ba 100644 --- a/desktop/source/deployment/misc/dp_platform.cxx +++ b/desktop/source/deployment/misc/dp_platform.cxx @@ -20,7 +20,6 @@ #include <dp_platform.hxx> #include <rtl/ustring.hxx> -#include <rtl/ustrbuf.hxx> #include <rtl/instance.hxx> #include <rtl/bootstrap.hxx> #include <osl/diagnose.h> @@ -54,11 +53,7 @@ namespace struct StrPlatform : public rtl::StaticWithInit< OUString, StrPlatform> { OUString operator () () { - OUStringBuffer buf; - buf.append( StrOperatingSystem::get() ); - buf.append( '_' ); - buf.append( StrCPU::get() ); - return buf.makeStringAndClear(); + return StrOperatingSystem::get() + "_" + StrCPU::get(); } }; diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index ac859a3d946f..218093c3587a 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -83,18 +83,16 @@ bool jarManifestHeaderPresent( OUString const & url, OUString const & name, Reference<XCommandEnvironment> const & xCmdEnv ) { - OUStringBuffer buf; - buf.append( "vnd.sun.star.zip://" ); - buf.append( - ::rtl::Uri::encode( + OUString buf = "vnd.sun.star.zip://" + + ::rtl::Uri::encode( url, rtl_UriCharClassRegName, rtl_UriEncodeIgnoreEscapes, - RTL_TEXTENCODING_UTF8 ) ); - buf.append( "/META-INF/MANIFEST.MF" ); + RTL_TEXTENCODING_UTF8 ) + + "/META-INF/MANIFEST.MF"; ::ucbhelper::Content manifestContent; OUString line; return create_ucb_content( - &manifestContent, buf.makeStringAndClear(), xCmdEnv, + &manifestContent, buf, xCmdEnv, false /* no throw */ ) && readLine( &line, name, manifestContent, RTL_TEXTENCODING_ASCII_US ); } diff --git a/desktop/source/deployment/registry/dp_registry.cxx b/desktop/source/deployment/registry/dp_registry.cxx index a061aa4382dc..91db8918e747 100644 --- a/desktop/source/deployment/registry/dp_registry.cxx +++ b/desktop/source/deployment/registry/dp_registry.cxx @@ -361,19 +361,16 @@ Reference<deployment::XPackageRegistry> PackageRegistryImpl::create( dp_misc::TRACE("> [dp_registry.cxx] media-type detection:\n\n" ); for (auto const& elem : that->m_filter2mediaType) { - OUStringBuffer buf; - buf.append( "extension \"" ); - buf.append( elem.first ); - buf.append( "\" maps to media-type \"" ); - buf.append( elem.second ); - buf.append( "\" maps to backend " ); const Reference<deployment::XPackageRegistry> xBackend( that->m_mediaType2backend.find( elem.second )->second ); allBackends.insert( xBackend ); - buf.append( Reference<lang::XServiceInfo>( + dp_misc::TRACE( + "extension \"" + elem.first + "\" maps to media-type \"" + elem.second + + "\" maps to backend " + + Reference<lang::XServiceInfo>( xBackend, UNO_QUERY_THROW ) - ->getImplementationName() ); - dp_misc::TRACE( buf.makeStringAndClear() + "\n"); + ->getImplementationName() + + "\n"); } dp_misc::TRACE( "> [dp_registry.cxx] ambiguous backends:\n\n" ); for (auto const& ambiguousBackend : that->m_ambiguousBackends) |