From e6328c4600466f35c2527172465c5c818717efee Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 27 Feb 2024 11:02:45 +0200 Subject: [PATCH] use more string view in linguistic Change-Id: Ib5c776f95b424128871a1676d996ae95b7048c64 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164016 Tested-by: Jenkins Reviewed-by: Noel Grandin --- include/linguistic/misc.hxx | 2 +- linguistic/source/misc.cxx | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/linguistic/misc.hxx b/include/linguistic/misc.hxx index 57c7179a2007..a9a7d074d63d 100644 --- a/include/linguistic/misc.hxx +++ b/include/linguistic/misc.hxx @@ -133,7 +133,7 @@ LNG_DLLPUBLIC bool IsUpper( const OUString &rText, sal_Int32 nPos, sal_In inline bool IsUpper( const OUString &rText, LanguageType nLanguage ) { return IsUpper( rText, 0, rText.getLength(), nLanguage ); } LNG_DLLPUBLIC CapType capitalType(const OUString&, CharClass const *); -LNG_DLLPUBLIC bool HasDigits( const OUString &rText ); +LNG_DLLPUBLIC bool HasDigits( std::u16string_view rText ); LNG_DLLPUBLIC bool IsNumeric( std::u16string_view rText ); diff --git a/linguistic/source/misc.cxx b/linguistic/source/misc.cxx index 5c50af6f1946..f80a849116eb 100644 --- a/linguistic/source/misc.cxx +++ b/linguistic/source/misc.cxx @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -625,14 +626,14 @@ const sal_uInt32 the_aDigitZeroes [] = 0x0001D7CE //1D7FF ; Decimal # Nd [50] MATHEMATICAL BOLD DIGIT ZERO..MATHEMATICAL MONOSPACE DIGIT NINE }; -bool HasDigits( const OUString &rText ) +bool HasDigits( std::u16string_view rText ) { - const sal_Int32 nLen = rText.getLength(); + const sal_Int32 nLen = rText.size(); sal_Int32 i = 0; while (i < nLen) // for all characters ... { - const sal_uInt32 nCodePoint = rText.iterateCodePoints( &i ); // handle unicode surrogates correctly... + const sal_uInt32 nCodePoint = o3tl::iterateCodePoints( rText, &i ); // handle unicode surrogates correctly... for (unsigned int nDigitZero : the_aDigitZeroes) // ... check in all 0..9 ranges { if (nDigitZero > nCodePoint)