[Libreoffice-commits] core.git: sal/rtl
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Sat Apr 10 20:10:41 UTC 2021
sal/rtl/strtmpl.hxx | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
New commits:
commit 5a11edc795d8a3ef1e15fc4e251f594911403131
Author: Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sat Apr 10 17:00:06 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Apr 10 22:10:02 2021 +0200
use std lib for sal_Unicode version of indexOfChar_WithLength
if possible, which will probably have a better word-at-a-time
algorithm.
Change-Id: Ia338a0aad81ef450d482701139f131d6d577b737
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113922
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sal/rtl/strtmpl.hxx b/sal/rtl/strtmpl.hxx
index a2677f7da0f2..d0f853f62feb 100644
--- a/sal/rtl/strtmpl.hxx
+++ b/sal/rtl/strtmpl.hxx
@@ -398,6 +398,14 @@ sal_Int32 indexOfChar_WithLength ( const IMPL_RTL_ST
IMPL_RTL_STRCODE* p = static_cast<IMPL_RTL_STRCODE*>(std::memchr(const_cast<IMPL_RTL_STRCODE *>(pStr), c, nLen));
return p ? p - pStr : -1;
}
+ else if constexpr (sizeof(IMPL_RTL_STRCODE) == sizeof(char16_t))
+ {
+ // take advantage of builtin optimisations
+ if (nLen <= 0) // char_traits::find takes an unsigned length
+ return -1;
+ char16_t const * p = std::char_traits<char16_t>::find(pStr, nLen, c);
+ return p ? p - pStr : -1;
+ }
else
{
const IMPL_RTL_STRCODE* pTempStr = pStr;
@@ -409,7 +417,6 @@ sal_Int32 indexOfChar_WithLength ( const IMPL_RTL_ST
pTempStr++;
nLen--;
}
-
return -1;
}
}
More information about the Libreoffice-commits
mailing list