vcl/source/gdi/CommonSalLayout.cxx |   15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

New commits:
commit 3344de28f6ddb559281d0b2c28f475a3e54fe7af
Author:     Khaled Hosny <kha...@aliftype.com>
AuthorDate: Fri Dec 30 17:39:24 2022 +0200
Commit:     خالد حسني <kha...@aliftype.com>
CommitDate: Fri Dec 30 20:23:22 2022 +0000

    vcl: Simplify this code and remove the funny comment
    
    Change-Id: Ia57f79ccb656eb570c4e481154eb6e74e2a32bd8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144879
    Tested-by: Jenkins
    Reviewed-by: خالد حسني <kha...@aliftype.com>

diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index 92b090222481..5997ea375192 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -772,21 +772,10 @@ void GenericSalLayout::ApplyDXArray(const double* 
pDXArray, const sal_Bool* pKas
             m_GlyphItems[i].addNewWidth(nDiff);
             m_GlyphItems[i].adjustLinearPosX(nDelta + nDiff);
 
-            // Warning:
-            // If you are tempted to improve the two loops below, think again.
-            // Even though I wrote this code, I no longer understand how it
-            // works, and every time I think I finally got it, I introduce a
-            // bug. - Khaled
-
             // Adjust the X position of the rest of the glyphs in the cluster.
-            size_t j = i;
-            while (j > 0)
-            {
-                --j;
-                if (!m_GlyphItems[j].IsInCluster())
-                    break;
+            // We iterate backwards since this is an RTL glyph.
+            for (int j = i - 1; j >= 0 && m_GlyphItems[j].IsInCluster(); j--)
                 m_GlyphItems[j].adjustLinearPosX(nDelta + nDiff);
-            }
 
             // This is a Kashida insertion position, mark it. Kashida glyphs
             // will be inserted below.

Reply via email to