From 1927b51993fb68907a75765676179b08ab195196 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 1 Apr 2022 17:42:34 +0200 Subject: loplugin:stringviewparam convert methods using indexOf .. and lastIndexOf, which convert to find and rfind Change-Id: I6c4156cf904774c0d867f85a4c2785dba7593f62 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132445 Tested-by: Jenkins Reviewed-by: Noel Grandin --- codemaker/source/cppumaker/dumputils.cxx | 14 +++++++------- codemaker/source/cppumaker/dumputils.hxx | 5 +++-- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'codemaker') diff --git a/codemaker/source/cppumaker/dumputils.cxx b/codemaker/source/cppumaker/dumputils.cxx index 15b62e04a407..8524b1962ce2 100644 --- a/codemaker/source/cppumaker/dumputils.cxx +++ b/codemaker/source/cppumaker/dumputils.cxx @@ -48,16 +48,16 @@ bool dumpNamespaceOpen( } bool dumpNamespaceClose( - FileStream & out, OUString const & entityName, bool fullModuleType) + FileStream & out, std::u16string_view entityName, bool fullModuleType) { bool bOutput = false; bool bFirst = true; - for (sal_Int32 i = 0; i >= 0;) { - i = entityName.indexOf('.', i); - if (i >= 0) { + for (size_t i = 0; i != std::u16string_view::npos;) { + i = entityName.find('.', i); + if (i != std::u16string_view::npos) { ++i; } - if (fullModuleType || i >= 0) { + if (fullModuleType || i != std::u16string_view::npos) { if (!bFirst) { out << " "; } @@ -69,8 +69,8 @@ bool dumpNamespaceClose( return bOutput; } -void dumpTypeIdentifier(FileStream & out, OUString const & entityName) { - out << entityName.subView(entityName.lastIndexOf('.') + 1); +void dumpTypeIdentifier(FileStream & out, std::u16string_view entityName) { + out << entityName.substr(entityName.rfind('.') + 1); } } diff --git a/codemaker/source/cppumaker/dumputils.hxx b/codemaker/source/cppumaker/dumputils.hxx index 58ccdc93fac5..2fcd708c43fb 100644 --- a/codemaker/source/cppumaker/dumputils.hxx +++ b/codemaker/source/cppumaker/dumputils.hxx @@ -20,6 +20,7 @@ #pragma once #include +#include namespace rtl { @@ -31,9 +32,9 @@ namespace codemaker::cppumaker { bool dumpNamespaceOpen(FileStream& out, rtl::OUString const& entityName, bool fullModuleType); -bool dumpNamespaceClose(FileStream& out, rtl::OUString const& entityName, bool fullModuleType); +bool dumpNamespaceClose(FileStream& out, std::u16string_view entityName, bool fullModuleType); -void dumpTypeIdentifier(FileStream& out, rtl::OUString const& entityName); +void dumpTypeIdentifier(FileStream& out, std::u16string_view entityName); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit