diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-11 14:49:08 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-11 17:44:46 +0200 |
commit | 6fc3dfd3f1b5cb13101299df42444f2ff0493846 (patch) | |
tree | 404a816727baa934e77c6e474cc57e83a7aa2754 /configmgr | |
parent | 8cbb08de38fc1a2f9d2ea0dfbdc2be8e8110ff73 (diff) |
use more string_view
found by tweaking the loplugin:stringview and making it whitelist
getLength
Change-Id: Ic41cd4e3026d93b70a76fe1279c6de3abbe6b4a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132820
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'configmgr')
-rw-r--r-- | configmgr/source/config_map.hxx | 6 | ||||
-rw-r--r-- | configmgr/source/data.cxx | 11 |
2 files changed, 9 insertions, 8 deletions
diff --git a/configmgr/source/config_map.hxx b/configmgr/source/config_map.hxx index af15f23ae9cf..5d2990d5a0d8 100644 --- a/configmgr/source/config_map.hxx +++ b/configmgr/source/config_map.hxx @@ -19,12 +19,12 @@ struct LengthContentsCompare { - bool operator()(const OUString& a, const OUString& b) const + bool operator()(std::u16string_view a, std::u16string_view b) const { - if (a.getLength() == b.getLength()) + if (a.size() == b.size()) return a < b; else - return a.getLength() < b.getLength(); + return a.size() < b.size(); } }; diff --git a/configmgr/source/data.cxx b/configmgr/source/data.cxx index 6279e02cf096..518d08513ad6 100644 --- a/configmgr/source/data.cxx +++ b/configmgr/source/data.cxx @@ -30,6 +30,7 @@ #include <rtl/ustring.hxx> #include <sal/log.hxx> #include <sal/types.h> +#include <o3tl/string_view.hxx> #include "additions.hxx" #include "data.hxx" @@ -43,23 +44,23 @@ namespace configmgr { namespace { bool decode( - OUString const & encoded, sal_Int32 begin, sal_Int32 end, + std::u16string_view encoded, sal_Int32 begin, sal_Int32 end, OUString * decoded) { assert( - begin >= 0 && begin <= end && end <= encoded.getLength() && + begin >= 0 && begin <= end && end <= static_cast<sal_Int32>(encoded.size()) && decoded != nullptr); OUStringBuffer buf(end - begin); while (begin != end) { sal_Unicode c = encoded[begin++]; if (c == '&') { - if (encoded.match("amp;", begin)) { + if (o3tl::starts_with(encoded.substr(begin), u"amp;")) { buf.append('&'); begin += RTL_CONSTASCII_LENGTH("amp;"); - } else if (encoded.match("quot;", begin)) { + } else if (o3tl::starts_with(encoded.substr(begin), u"quot;")) { buf.append('"'); begin += RTL_CONSTASCII_LENGTH("quot;"); - } else if (encoded.match("apos;", begin)) { + } else if (o3tl::starts_with(encoded.substr(begin), u"apos;")) { buf.append('\''); begin += RTL_CONSTASCII_LENGTH("apos;"); } else { |