summaryrefslogtreecommitdiff
path: root/unoidl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-04-10 15:36:21 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-04-10 20:15:16 +0200
commitb24a4d255d31233c48152e6e1ce992a693cdaeae (patch)
treee0ad8f574d3b1ddcad3d81ec3ac438777ca4846d /unoidl
parent57f22d9b1a4e1cd161a35c8e4c390661db981d2c (diff)
use more string_view
found by tweaking the loplugin:stringview and making it whitelist getLength Change-Id: Ic15d3703d1fb07658e99e1db1c89e2fa5bc70c19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132771 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'unoidl')
-rw-r--r--unoidl/source/sourceprovider-parser.y9
-rw-r--r--unoidl/source/sourcetreeprovider.cxx8
-rw-r--r--unoidl/source/unoidlprovider.cxx12
3 files changed, 15 insertions, 14 deletions
diff --git a/unoidl/source/sourceprovider-parser.y b/unoidl/source/sourceprovider-parser.y
index 0175b5379897..2c076f08ac70 100644
--- a/unoidl/source/sourceprovider-parser.y
+++ b/unoidl/source/sourceprovider-parser.y
@@ -17,6 +17,7 @@
#include <sal/config.h>
#include <o3tl/unreachable.hxx>
+#include <o3tl/string_view.hxx>
#include <rtl/ustrbuf.hxx>
#include <unoidl/unoidl.hxx>
@@ -165,11 +166,11 @@ template<typename T> rtl::Reference<T> getCurrentPad(
return pad;
}
-bool nameHasSameIdentifierAs(OUString const & name, OUString const & identifier)
+bool nameHasSameIdentifierAs(std::u16string_view name, std::u16string_view identifier)
{
- sal_Int32 i = name.lastIndexOf('.') + 1;
- return identifier.getLength() == name.getLength() - i
- && name.match(identifier, i);
+ size_t i = name.rfind('.') + 1;
+ return identifier.size() == name.size() - i
+ && o3tl::starts_with(name.substr(i), identifier);
}
bool coerce(
diff --git a/unoidl/source/sourcetreeprovider.cxx b/unoidl/source/sourcetreeprovider.cxx
index 404938c376cc..fea67405cd54 100644
--- a/unoidl/source/sourcetreeprovider.cxx
+++ b/unoidl/source/sourcetreeprovider.cxx
@@ -126,9 +126,9 @@ private:
OUString uri_;
};
-bool isValidFileName(OUString const & name, bool directory) {
- for (sal_Int32 i = 0;; ++i) {
- if (i == name.getLength()) {
+bool isValidFileName(std::u16string_view name, bool directory) {
+ for (size_t i = 0;; ++i) {
+ if (i == name.size()) {
if (i == 0) {
return false;
}
@@ -139,7 +139,7 @@ bool isValidFileName(OUString const & name, bool directory) {
if (i == 0 || name[i - 1] == '_') {
return false;
}
- return !directory && name.subView(i + 1) == u"idl";
+ return !directory && name.substr(i + 1) == u"idl";
} else if (c == '_') {
//TODO: Ignore case of name[0] only for case-insensitive file systems:
if (i == 0 || name[i - 1] == '_') {
diff --git a/unoidl/source/unoidlprovider.cxx b/unoidl/source/unoidlprovider.cxx
index 217251dca053..e7816afdb2be 100644
--- a/unoidl/source/unoidlprovider.cxx
+++ b/unoidl/source/unoidlprovider.cxx
@@ -183,14 +183,14 @@ bool isSimpleType(std::u16string_view type) {
// <other> ::= <capital> | "a"--"z" | "0"--"9"
// <capital> ::= "A"--"Z"
//
-bool isIdentifier(OUString const & type, bool scoped) {
- if (type.isEmpty()) {
+bool isIdentifier(std::u16string_view type, bool scoped) {
+ if (type.empty()) {
return false;
}
- for (sal_Int32 i = 0; i != type.getLength(); ++i) {
+ for (size_t i = 0; i != type.size(); ++i) {
sal_Unicode c = type[i];
if (c == '.') {
- if (!scoped || i == 0 || i == type.getLength() - 1
+ if (!scoped || i == 0 || i == type.size() - 1
|| type[i - 1] == '.')
{
return false;
@@ -247,11 +247,11 @@ void checkTypeName(
}
void checkEntityName(
- rtl::Reference< MappedFile > const & file, OUString const & name)
+ rtl::Reference< MappedFile > const & file, std::u16string_view name)
{
if (isSimpleType(name) || !isIdentifier(name, false)) {
throw FileFormatException(
- file->uri, "UNOIDL format: bad entity name \"" + name + "\"");
+ file->uri, OUString::Concat("UNOIDL format: bad entity name \"") + name + "\"");
}
}