diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-11-12 08:13:40 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-11-12 16:53:30 +0100 |
commit | f34ac579fac16fff37bf00fe85d43ad6b938eca7 (patch) | |
tree | 0747c4d86bbf40a5093fb7a3215dd52a8e8586b2 /framework | |
parent | c45753847dfc2b4645dc2f7500a18ec2c5d438df (diff) |
New loplugin:stringviewparam
...to "Find functions that take rtl::O[U]String parameters that can be
generalized to take std::[u16]string_view instead." (Which in turn can avoid
costly O[U]String constructions, see e.g. loplugin:stringview and subView.)
Some of those functions' call sites, passing plain char string literals, needed
to be adapted when converting them.
Change-Id: I644ab546d7a0ce9e470ab9b3196e3e60d1e812bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105622
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'framework')
-rw-r--r-- | framework/inc/uielement/menubarmerger.hxx | 7 | ||||
-rw-r--r-- | framework/inc/uielement/statusbarmerger.hxx | 6 | ||||
-rw-r--r-- | framework/source/uielement/menubarmerger.cxx | 5 | ||||
-rw-r--r-- | framework/source/uielement/statusbarmerger.cxx | 4 | ||||
-rw-r--r-- | framework/source/uifactory/addonstoolbarfactory.cxx | 8 |
5 files changed, 21 insertions, 9 deletions
diff --git a/framework/inc/uielement/menubarmerger.hxx b/framework/inc/uielement/menubarmerger.hxx index 139c40efc818..8646563b86d8 100644 --- a/framework/inc/uielement/menubarmerger.hxx +++ b/framework/inc/uielement/menubarmerger.hxx @@ -24,6 +24,8 @@ #include <rtl/ustring.hxx> #include <vcl/menu.hxx> + +#include <string_view> #include <vector> namespace framework @@ -58,7 +60,8 @@ struct ReferencePathInfo namespace MenuBarMerger { - bool IsCorrectContext( const OUString& aContext, const OUString& aModuleIdentifier ); + bool IsCorrectContext( + const OUString& aContext, std::u16string_view aModuleIdentifier ); void RetrieveReferencePath( const OUString&, std::vector< OUString >& aReferencePath ); @@ -81,7 +84,7 @@ namespace MenuBarMerger const OUString& rMergeCommand, const OUString& rMergeFallback, const ::std::vector< OUString >& rReferencePath, - const OUString& rModuleIdentifier, + std::u16string_view rModuleIdentifier, const AddonMenuContainer& rAddonMenuItems ); bool MergeMenuItems( Menu* pMenu, sal_uInt16 nPos, diff --git a/framework/inc/uielement/statusbarmerger.hxx b/framework/inc/uielement/statusbarmerger.hxx index 73aa7fd472f0..497862fae127 100644 --- a/framework/inc/uielement/statusbarmerger.hxx +++ b/framework/inc/uielement/statusbarmerger.hxx @@ -19,6 +19,10 @@ #ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_STATUSBARMERGER_HXX #define INCLUDED_FRAMEWORK_INC_UIELEMENT_STATUSBARMERGER_HXX +#include <sal/config.h> + +#include <string_view> + #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/uno/Sequence.hxx> #include <rtl/ustring.hxx> @@ -45,7 +49,7 @@ typedef ::std::vector< AddonStatusbarItem > AddonStatusbarItemContainer; namespace StatusbarMerger { - bool IsCorrectContext( const OUString& aContext ); + bool IsCorrectContext( std::u16string_view aContext ); bool ConvertSeqSeqToVector( const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& rSequence, AddonStatusbarItemContainer& rContainer ); diff --git a/framework/source/uielement/menubarmerger.cxx b/framework/source/uielement/menubarmerger.cxx index 526b4fb5fb81..532cab083b7d 100644 --- a/framework/source/uielement/menubarmerger.cxx +++ b/framework/source/uielement/menubarmerger.cxx @@ -55,7 +55,8 @@ namespace framework description of css::frame::XModuleManager. */ -bool MenuBarMerger::IsCorrectContext( const OUString& rContext, const OUString& rModuleIdentifier ) +bool MenuBarMerger::IsCorrectContext( + const OUString& rContext, std::u16string_view rModuleIdentifier ) { return ( rContext.isEmpty() || ( rContext.indexOf( rModuleIdentifier ) >= 0 )); } @@ -309,7 +310,7 @@ bool MenuBarMerger::ProcessFallbackOperation( const OUString& rMergeCommand, const OUString& rMergeFallback, const ::std::vector< OUString >& rReferencePath, - const OUString& rModuleIdentifier, + const std::u16string_view rModuleIdentifier, const AddonMenuContainer& rAddonMenuItems ) { if (( rMergeFallback == MERGEFALLBACK_IGNORE ) || diff --git a/framework/source/uielement/statusbarmerger.cxx b/framework/source/uielement/statusbarmerger.cxx index ed6948a70e1a..5b3868e9a0ac 100644 --- a/framework/source/uielement/statusbarmerger.cxx +++ b/framework/source/uielement/statusbarmerger.cxx @@ -152,9 +152,9 @@ bool lcl_RemoveItems( StatusBar* pStatusbar, } bool StatusbarMerger::IsCorrectContext( - const OUString& rContext ) + std::u16string_view rContext ) { - return rContext.isEmpty(); + return rContext.empty(); } bool StatusbarMerger::ConvertSeqSeqToVector( diff --git a/framework/source/uifactory/addonstoolbarfactory.cxx b/framework/source/uifactory/addonstoolbarfactory.cxx index 0c3f5d4fba7c..63742c89249c 100644 --- a/framework/source/uifactory/addonstoolbarfactory.cxx +++ b/framework/source/uifactory/addonstoolbarfactory.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <string_view> + #include <uielement/addonstoolbarwrapper.hxx> #include <com/sun/star/frame/ModuleManager.hpp> @@ -79,12 +83,12 @@ AddonsToolBarFactory::AddonsToolBarFactory( { } -bool IsCorrectContext( const OUString& rModuleIdentifier, const OUString& aContextList ) +bool IsCorrectContext( std::u16string_view rModuleIdentifier, const OUString& aContextList ) { if ( aContextList.isEmpty() ) return true; - if ( !rModuleIdentifier.isEmpty() ) + if ( !rModuleIdentifier.empty() ) { sal_Int32 nIndex = aContextList.indexOf( rModuleIdentifier ); return ( nIndex >= 0 ); |