From 7840effb1d5efd1fd7f6798c7c504b05292a7793 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 22 Feb 2024 12:59:26 +0200 Subject: use more string_view found by tweaking the stringview loplugin Change-Id: I92203ba99642bef7951ffa146184c5562cb31d09 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163744 Tested-by: Jenkins Reviewed-by: Noel Grandin --- comphelper/qa/string/test_string.cxx | 8 ++++---- comphelper/source/misc/string.cxx | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'comphelper') diff --git a/comphelper/qa/string/test_string.cxx b/comphelper/qa/string/test_string.cxx index 5d25a64da887..ac79148a4c48 100644 --- a/comphelper/qa/string/test_string.cxx +++ b/comphelper/qa/string/test_string.cxx @@ -197,15 +197,15 @@ void TestString::testReverseString() } void TestString::testReverseCodePoints() { - CPPUNIT_ASSERT_EQUAL(OUString(), comphelper::string::reverseCodePoints("")); - CPPUNIT_ASSERT_EQUAL(OUString("cba"), comphelper::string::reverseCodePoints("abc")); + CPPUNIT_ASSERT_EQUAL(OUString(), comphelper::string::reverseCodePoints(u"")); + CPPUNIT_ASSERT_EQUAL(OUString("cba"), comphelper::string::reverseCodePoints(u"abc")); CPPUNIT_ASSERT_EQUAL( u"w\U0010FFFFv\U00010000u"_ustr, - comphelper::string::reverseCodePoints(u"u\U00010000v\U0010FFFFw"_ustr)); + comphelper::string::reverseCodePoints(u"u\U00010000v\U0010FFFFw")); static sal_Unicode const malformed[] = {0xDC00, 0xD800}; CPPUNIT_ASSERT_EQUAL( u"\U00010000"_ustr, - comphelper::string::reverseCodePoints(OUString(malformed, std::size(malformed)))); + comphelper::string::reverseCodePoints(std::u16string_view(malformed, std::size(malformed)))); } void TestString::testSplit() diff --git a/comphelper/source/misc/string.cxx b/comphelper/source/misc/string.cxx index e17951fc43be..1b9137e473c0 100644 --- a/comphelper/source/misc/string.cxx +++ b/comphelper/source/misc/string.cxx @@ -525,11 +525,11 @@ OUString reverseString(std::u16string_view rStr) return sBuf.makeStringAndClear(); } -OUString reverseCodePoints(OUString const & str) { - auto const len = str.getLength(); +OUString reverseCodePoints(std::u16string_view str) { + auto const len = str.size(); OUStringBuffer buf(len); - for (auto i = len; i != 0;) { - buf.appendUtf32(str.iterateCodePoints(&i, -1)); + for (sal_Int32 i = len; i != 0;) { + buf.appendUtf32(o3tl::iterateCodePoints(str, &i, -1)); } return buf.makeStringAndClear(); } -- cgit