summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2024-02-22 12:59:26 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-03-08 07:06:13 +0100
commit7840effb1d5efd1fd7f6798c7c504b05292a7793 (patch)
tree845e03d4c2cfad1d5bbcaaf9dc3ec1aeece7c864 /comphelper
parentbf35f2b36fc00f9b37397422b2ee425c6a697540 (diff)
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/qa/string/test_string.cxx8
-rw-r--r--comphelper/source/misc/string.cxx8
2 files changed, 8 insertions, 8 deletions
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();
}