Using static non-thread-local variables as cache is scary

I think that these functions may easily be used in different threads.
No idea how useful the cache is (if at all: do we call the functions
repeatedly for same character often enough?); but at least it must be
correct.

Change-Id: Ide2f7317bed55e201cd075ca93ee617e16a2654e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192678
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2025-10-20 11:07:17 +02:00
parent fc2948b208
commit ae2b099101
+4 -4
View File
@@ -69,8 +69,8 @@ unicode::getUnicodeScriptEnd( UnicodeScript type) {
sal_Int16
unicode::getUnicodeType(const sal_uInt32 ch)
{
static sal_uInt32 c = 0x00;
static sal_uInt32 r = 0x00;
static thread_local sal_uInt32 c = 0x00;
static thread_local sal_Int16 r = 0x00;
if (ch == c) return r;
else c = ch;
@@ -174,8 +174,8 @@ unicode::getUnicodeType(const sal_uInt32 ch)
sal_uInt8
unicode::getUnicodeDirection( const sal_Unicode ch ) {
static sal_Unicode c = 0x00;
static sal_uInt8 r = 0x00;
static thread_local sal_Unicode c = 0x00;
static thread_local sal_uInt8 r = 0x00;
if (ch == c) return r;
else c = ch;