Revert "use more string_view in codemaker"
This reverts commit 9463550eab.
Reason for revert: The codemaker::UnoType::decompose was previously mostly returning the same OString it receives, so this change is likely a pessimisation
Change-Id: Ie1b41889d0a6af9247b8683075d4edd1163fecc8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133492
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -26,25 +26,25 @@
|
||||
|
||||
|
||||
OString codemaker::UnoType::decompose(
|
||||
std::string_view type, sal_Int32 * rank,
|
||||
OString const & type, sal_Int32 * rank,
|
||||
std::vector< OString > * arguments)
|
||||
{
|
||||
size_t len = type.size();
|
||||
size_t i = 0;
|
||||
sal_Int32 len = type.getLength();
|
||||
sal_Int32 i = 0;
|
||||
while (len - i > 1 && type[i + 1] == ']') {
|
||||
i += 2;
|
||||
}
|
||||
if (rank != nullptr) {
|
||||
*rank = i / 2;
|
||||
}
|
||||
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 j = arguments == nullptr ? -1 : type.indexOf('<', i);
|
||||
if (j < 0) {
|
||||
return type.copy(i);
|
||||
}
|
||||
size_t k = j;
|
||||
sal_Int32 k = j;
|
||||
do {
|
||||
++k; // skip '<' or ','
|
||||
size_t l = k;
|
||||
sal_Int32 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(OString(type.substr(k, l - k)));
|
||||
arguments->push_back(type.copy(k, l - k));
|
||||
k = l;
|
||||
} while (k != len && type[k] != '>');
|
||||
OSL_ASSERT(k == len - 1 && type[k] == '>');
|
||||
return OString(type.substr(i, j - i));
|
||||
return type.copy(i, j - i);
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
@@ -68,7 +68,7 @@ Includes::Includes(
|
||||
Includes::~Includes()
|
||||
{}
|
||||
|
||||
void Includes::add(std::string_view entityName) {
|
||||
void Includes::add(OString const & entityName) {
|
||||
sal_Int32 k;
|
||||
std::vector< OString > args;
|
||||
OUString n(b2u(codemaker::UnoType::decompose(entityName, &k, &args)));
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
|
||||
~Includes();
|
||||
|
||||
void add(std::string_view entityName);
|
||||
void add(OString const & entityName);
|
||||
void addCassert() { m_includeCassert = true; }
|
||||
void addAny() { m_includeAny = true; }
|
||||
void addReference() { m_includeReference = true; }
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#include <sal/types.h>
|
||||
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace rtl { class OString; }
|
||||
@@ -79,7 +78,7 @@ namespace codemaker::UnoType {
|
||||
@return the base part of the given type
|
||||
*/
|
||||
rtl::OString decompose(
|
||||
std::string_view type, sal_Int32 * rank = nullptr,
|
||||
rtl::OString const & type, sal_Int32 * rank = nullptr,
|
||||
std::vector< rtl::OString > * arguments = nullptr);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user