external/icu/UnpackedTarball_icu.mk                                     |    1 
 external/icu/do-not-reset-useful-cache-to-empty-in-populateNear.patch.2 |   37 
++++++++++
 2 files changed, 38 insertions(+)

New commits:
commit c5199abfc1a468b28c680faf41e2f11bc1729c47
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Thu Apr 7 17:01:16 2022 +0200
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Thu Apr 7 23:14:53 2022 +0200

    work around ICU performance problem in text breaking (tdf#116400)
    
    Reported upstream at https://unicode-org.atlassian.net/browse/ICU-21946 ,
    they've confirmed the problem, but so far no actual code change. So
    let's push my patch for now.
    
    Change-Id: Idd92ca66eea9b28103ad890aec66c40029ec7ebd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132676
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/external/icu/UnpackedTarball_icu.mk 
b/external/icu/UnpackedTarball_icu.mk
index 58a05f1ee39b..25b4f1defa26 100644
--- a/external/icu/UnpackedTarball_icu.mk
+++ b/external/icu/UnpackedTarball_icu.mk
@@ -43,6 +43,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,icu,\
        external/icu/icu4c-use-pkgdata-single-ccode-file-mode.patch.1 \
        external/icu/icu4c-$(if $(filter ANDROID,$(OS)),android,rpath).patch.1 \
        $(if $(filter-out 
ANDROID,$(OS)),external/icu/icu4c-icudata-stdlibs.patch.1) \
+       external/icu/do-not-reset-useful-cache-to-empty-in-populateNear.patch.2 
\
 ))
 
 $(eval $(call 
gb_UnpackedTarball_add_file,icu,source/data/brkitr/khmerdict.dict,external/icu/khmerdict.dict))
diff --git 
a/external/icu/do-not-reset-useful-cache-to-empty-in-populateNear.patch.2 
b/external/icu/do-not-reset-useful-cache-to-empty-in-populateNear.patch.2
new file mode 100644
index 000000000000..bd7fe74fb42a
--- /dev/null
+++ b/external/icu/do-not-reset-useful-cache-to-empty-in-populateNear.patch.2
@@ -0,0 +1,37 @@
+From 34b2f7174ba187d99dfb8704b9cf19d369accc13 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= <l.lu...@centrum.cz>
+Date: Wed, 16 Mar 2022 10:54:03 +0100
+Subject: [PATCH] do not reset useful cache to empty in populateNear()
+
+---
+ icu4c/source/common/rbbi_cache.cpp | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/icu4c/source/common/rbbi_cache.cpp 
b/icu4c/source/common/rbbi_cache.cpp
+index 26d82df781..54a77c97c6 100644
+--- a/icu/source/common/rbbi_cache.cpp
++++ b/icu/source/common/rbbi_cache.cpp
+@@ -352,7 +352,7 @@ UBool RuleBasedBreakIterator::BreakCache
+     if ((position < fBoundaries[fStartBufIdx] - 15) || position > 
(fBoundaries[fEndBufIdx] + 15)) {
+         int32_t aBoundary = 0;
+         int32_t ruleStatusIndex = 0;
+-        if (position > 20) {
++        if (position > 20 && false) { // handleSafePrevious() is broken and 
always returns 0
+             int32_t backupPos = fBI->handleSafePrevious(position);
+ 
+             if (backupPos > 0) {
+@@ -376,7 +376,10 @@ UBool 
RuleBasedBreakIterator::BreakCache::populateNear(int32_t position, UErrorC
+                 ruleStatusIndex = fBI->fRuleStatusIndex;
+             }
+         }
+-        reset(aBoundary, ruleStatusIndex);        // Reset cache to hold 
aBoundary as a single starting point.
++        // Reset cache to hold aBoundary as a single starting point.
++        // Do not do so if what's in the cache is still more useful than an 
empty cache.
++        if (!(aBoundary == 0 && position > fBoundaries[fEndBufIdx]))
++            reset(aBoundary, ruleStatusIndex);
+     }
+ 
+     // Fill in boundaries between existing cache content and the new 
requested position.
+-- 
+2.34.1
+

Reply via email to