summaryrefslogtreecommitdiff
path: root/i18npool
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-05-13 11:57:17 +0200
committerStephan Bergmann <sbergman@redhat.com>2021-05-14 13:11:50 +0200
commitaf16aa625682b649e8843237652b9246d519cbae (patch)
tree2ea597c328318d6b75761b71af313bef02b5ad77 /i18npool
parentf40cbba63f13e7081fc5901769651fd4d43ea34d (diff)
Improve loplugin:stringview
Issue the "instead of O[U]String, pass [u16]string_view" diagnostic also for operator call arguments. (The "rather than copy, pass subView()" diagnostic is already part of handleSubExprThatCouldBeView, so no need to repeat it explicitly for operator call arguments.) (And many call sites don't even require an explicit [u16]string_view, esp. with the recent ad48b2b02f83eed41fb1eb8d16de7e804156fcf1 "Optimized OString operator += overloads". Just some test code in sal/qa/ that explicitly tests the O[U]String functionality had to be excluded.) Change-Id: I8d55ba5a7fa16a563f5ffe43d245125c88c793bc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115589 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/qa/cppunit/test_breakiterator.cxx5
-rw-r--r--i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx2
-rw-r--r--i18npool/source/localedata/localedata.cxx3
3 files changed, 6 insertions, 4 deletions
diff --git a/i18npool/qa/cppunit/test_breakiterator.cxx b/i18npool/qa/cppunit/test_breakiterator.cxx
index 91b9a0acbe03..a12949c952e1 100644
--- a/i18npool/qa/cppunit/test_breakiterator.cxx
+++ b/i18npool/qa/cppunit/test_breakiterator.cxx
@@ -19,6 +19,7 @@
#include <string.h>
#include <stack>
+#include <string_view>
using namespace ::com::sun::star;
@@ -798,7 +799,7 @@ void TestBreakIterator::testWeak()
sal_Int16 nScript = m_xBreak->getScriptType(aWeaks, i);
OString aMsg =
"Char 0x" +
- OString::number(static_cast<sal_Int32>(OUString(aWeaks)[i]), 16) +
+ OString::number(static_cast<sal_Int32>(std::u16string_view(aWeaks)[i]), 16) +
" should have been weak";
CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsg.getStr(),
i18n::ScriptType::WEAK, nScript);
@@ -834,7 +835,7 @@ void TestBreakIterator::testAsian()
sal_Int16 nScript = m_xBreak->getScriptType(aAsians, i);
OString aMsg =
"Char 0x" +
- OString::number(static_cast<sal_Int32>(OUString(aAsians)[i]), 16) +
+ OString::number(static_cast<sal_Int32>(std::u16string_view(aAsians)[i]), 16) +
" should have been asian";
CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsg.getStr(),
i18n::ScriptType::ASIAN, nScript);
diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
index af020c207faf..dadfc13b86a0 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -961,7 +961,7 @@ DefaultNumberingProvider::makeNumberingString( const Sequence<beans::PropertyVal
if ( number > tableSize && !bRecycleSymbol)
result += OUString::number( number);
else
- result += OUString(&table[--number % tableSize], 1);
+ result += OUStringChar(table[--number % tableSize]);
}
// append suffix
diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx
index 40dd0a300cc5..0f3b03a2689a 100644
--- a/i18npool/source/localedata/localedata.cxx
+++ b/i18npool/source/localedata/localedata.cxx
@@ -18,6 +18,7 @@
*/
#include <memory>
+#include <string_view>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
@@ -703,7 +704,7 @@ Sequence< CalendarItem2 > LocaleDataImpl::getCalendarItems(
const Locale & rLocale, const Sequence< Calendar2 > & calendarsSeq )
{
Sequence< CalendarItem2 > aItems;
- if ( OUString( allCalendars[rnOffset] ) == "ref" )
+ if ( allCalendars[rnOffset] == std::u16string_view(u"ref") )
{
aItems = getCalendarItemByName( OUString( allCalendars[rnOffset+1]), rLocale, calendarsSeq, nWhichItem);
rnOffset += 2;