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 /vcl/source | |
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 'vcl/source')
-rw-r--r-- | vcl/source/app/stdtext.cxx | 2 | ||||
-rw-r--r-- | vcl/source/control/field2.cxx | 4 | ||||
-rw-r--r-- | vcl/source/helper/driverblocklist.cxx | 5 | ||||
-rw-r--r-- | vcl/source/window/builder.cxx | 5 | ||||
-rw-r--r-- | vcl/source/window/layout.cxx | 4 |
5 files changed, 11 insertions, 9 deletions
diff --git a/vcl/source/app/stdtext.cxx b/vcl/source/app/stdtext.cxx index 7d6bae82016c..0d5e8411bc60 100644 --- a/vcl/source/app/stdtext.cxx +++ b/vcl/source/app/stdtext.cxx @@ -25,7 +25,7 @@ #include <svdata.hxx> void ShowServiceNotAvailableError(weld::Widget* pParent, - const OUString& rServiceName, bool bError) + std::u16string_view rServiceName, bool bError) { OUString aText = VclResId(SV_STDTEXT_SERVICENOTAVAILABLE).replaceAll("%s", rServiceName); std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent, diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx index 7fbeed108d99..fc39b48de12d 100644 --- a/vcl/source/control/field2.cxx +++ b/vcl/source/control/field2.cxx @@ -461,7 +461,7 @@ static void ImplPatternProcessStrictModify( weld::Entry& rEntry, rEntry.select_region(nStartPos, nEndPos); } -static sal_Int32 ImplPatternLeftPos(const OString& rEditMask, sal_Int32 nCursorPos) +static sal_Int32 ImplPatternLeftPos(std::string_view rEditMask, sal_Int32 nCursorPos) { // search non-literal predecessor sal_Int32 nNewPos = nCursorPos; @@ -1193,7 +1193,7 @@ static sal_uInt16 ImplCutNumberFromString( OUString& rStr ) return nValue; } -static bool ImplCutMonthName( OUString& rStr, const OUString& _rLookupMonthName ) +static bool ImplCutMonthName( OUString& rStr, std::u16string_view _rLookupMonthName ) { sal_Int32 index = 0; rStr = rStr.replaceFirst(_rLookupMonthName, "", &index); diff --git a/vcl/source/helper/driverblocklist.cxx b/vcl/source/helper/driverblocklist.cxx index 0fb1edd73f75..a24cdc98fbcb 100644 --- a/vcl/source/helper/driverblocklist.cxx +++ b/vcl/source/helper/driverblocklist.cxx @@ -596,7 +596,8 @@ DriverInfo::DriverInfo(OperatingSystem os, const OUString& vendor, VersionCompar } bool FindBlocklistedDeviceInList(std::vector<DriverInfo>& aDeviceInfos, VersionType versionType, - OUString const& sDriverVersion, OUString const& sAdapterVendorID, + OUString const& sDriverVersion, + std::u16string_view sAdapterVendorID, OUString const& sAdapterDeviceID, OperatingSystem system, const OUString& blocklistURL) { @@ -700,7 +701,7 @@ bool FindBlocklistedDeviceInList(std::vector<DriverInfo>& aDeviceInfos, VersionT } bool IsDeviceBlocked(const OUString& blocklistURL, VersionType versionType, - const OUString& driverVersion, const OUString& vendorId, + const OUString& driverVersion, std::u16string_view vendorId, const OUString& deviceId) { std::vector<DriverInfo> driverList; diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 3e9200df6d2e..c1163335aaff 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -11,6 +11,7 @@ #include <config_options.h> #include <memory> +#include <string_view> #include <unordered_map> #include <com/sun/star/accessibility/AccessibleRole.hpp> @@ -76,9 +77,9 @@ #include <dlfcn.h> #endif -static bool toBool(const OString &rValue) +static bool toBool(std::string_view rValue) { - return (!rValue.isEmpty() && (rValue[0] == 't' || rValue[0] == 'T' || rValue[0] == '1')); + return (!rValue.empty() && (rValue[0] == 't' || rValue[0] == 'T' || rValue[0] == '1')); } namespace diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index 6aa30005942e..245befc2c3a7 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -1318,9 +1318,9 @@ void VclGrid::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) rJsonWriter.put("type", "grid"); } -bool toBool(const OUString &rValue) +bool toBool(std::u16string_view rValue) { - return (!rValue.isEmpty() && (rValue[0] == 't' || rValue[0] == 'T' || rValue[0] == '1')); + return (!rValue.empty() && (rValue[0] == 't' || rValue[0] == 'T' || rValue[0] == '1')); } bool VclGrid::set_property(const OString &rKey, const OUString &rValue) |