use more string_view in codemaker
Change-Id: If311f5600bd61387cc709065978306c21360dea8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133509
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/codemaker/source/codemaker/unotype.cxx b/codemaker/source/codemaker/unotype.cxx
index 8c25ac8..2b8a2bf 100644
--- a/codemaker/source/codemaker/unotype.cxx
+++ b/codemaker/source/codemaker/unotype.cxx
@@ -26,25 +26,25 @@
OString codemaker::UnoType::decompose(
OString const & type, sal_Int32 * rank,
std::string_view type, sal_Int32 * rank,
std::vector< OString > * arguments)
{
sal_Int32 len = type.getLength();
sal_Int32 i = 0;
size_t len = type.size();
size_t i = 0;
while (len - i > 1 && type[i + 1] == ']') {
i += 2;
}
if (rank != nullptr) {
*rank = i / 2;
}
sal_Int32 j = arguments == nullptr ? -1 : type.indexOf('<', i);
if (j < 0) {
return type.copy(i);
size_t j = arguments == nullptr ? std::string_view::npos : type.find('<', i);
if (j == std::string_view::npos) {
return OString(type.substr(i));
}
sal_Int32 k = j;
size_t k = j;
do {
++k; // skip '<' or ','
sal_Int32 l = k;
size_t l = k;
for (sal_Int32 level = 0; l != len; ++l) {
char c = type[l];
if (c == ',') {
@@ -60,11 +60,11 @@ OString codemaker::UnoType::decompose(
--level;
}
}
arguments->push_back(type.copy(k, l - k));
arguments->push_back(OString(type.substr(k, l - k)));
k = l;
} while (k != len && type[k] != '>');
OSL_ASSERT(k == len - 1 && type[k] == '>');
return type.copy(i, j - i);
return OString(type.substr(i, j - i));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/codemaker/source/cppumaker/includes.cxx b/codemaker/source/cppumaker/includes.cxx
index db7dae46..470d59e 100644
--- a/codemaker/source/cppumaker/includes.cxx
+++ b/codemaker/source/cppumaker/includes.cxx
@@ -68,7 +68,7 @@ Includes::Includes(
Includes::~Includes()
{}
void Includes::add(OString const & entityName) {
void Includes::add(std::string_view entityName) {
sal_Int32 k;
std::vector< OString > args;
OUString n(b2u(codemaker::UnoType::decompose(entityName, &k, &args)));
diff --git a/codemaker/source/cppumaker/includes.hxx b/codemaker/source/cppumaker/includes.hxx
index 0362c41..00c78440 100644
--- a/codemaker/source/cppumaker/includes.hxx
+++ b/codemaker/source/cppumaker/includes.hxx
@@ -38,7 +38,7 @@ public:
~Includes();
void add(OString const & entityName);
void add(std::string_view entityName);
void addCassert() { m_includeCassert = true; }
void addAny() { m_includeAny = true; }
void addReference() { m_includeReference = true; }
diff --git a/include/codemaker/unotype.hxx b/include/codemaker/unotype.hxx
index 6063218..38c66f6 100644
--- a/include/codemaker/unotype.hxx
+++ b/include/codemaker/unotype.hxx
@@ -22,6 +22,7 @@
#include <sal/types.h>
#include <string_view>
#include <vector>
namespace rtl { class OString; }
@@ -78,7 +79,7 @@ namespace codemaker::UnoType {
@return the base part of the given type
*/
rtl::OString decompose(
rtl::OString const & type, sal_Int32 * rank = nullptr,
std::string_view type, sal_Int32 * rank = nullptr,
std::vector< rtl::OString > * arguments = nullptr);
}