[Libreoffice-commits] core.git: vcl/unx

Khaled Hosny khaledhosny at eglug.org
Wed May 18 00:08:48 UTC 2016


 vcl/unx/generic/glyphs/gcach_layout.cxx |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

New commits:
commit f688acfdae00ebdd891737e533d54368810185e1
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Tue May 17 22:49:40 2016 +0200

    Try to fix perf regression in HbLayoutEngine::Layout()
    
    Regression from 1da9b4c24e806ad2447b4a656e2a7192755bb6a8. We should
    cache the break iterator as creating it is pretty expensive.
    
    Change-Id: Id9bbe9aa9835d1b38bc7c8219464ee9c62335325
    Reviewed-on: https://gerrit.libreoffice.org/25073
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/vcl/unx/generic/glyphs/gcach_layout.cxx b/vcl/unx/generic/glyphs/gcach_layout.cxx
index 61d1477..f2afa9a 100644
--- a/vcl/unx/generic/glyphs/gcach_layout.cxx
+++ b/vcl/unx/generic/glyphs/gcach_layout.cxx
@@ -326,6 +326,7 @@ private:
     hb_script_t             maHbScript;
     hb_face_t*              mpHbFace;
     int                     mnUnitsPerEM;
+    css::uno::Reference<css::i18n::XBreakIterator> mxBreak;
 
 public:
     explicit                HbLayoutEngine(ServerFont&);
@@ -514,7 +515,8 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
 
             sal_Int32 nGraphemeStartPos = std::numeric_limits<sal_Int32>::max();
             sal_Int32 nGraphemeEndPos = std::numeric_limits<sal_Int32>::min();
-            css::uno::Reference<css::i18n::XBreakIterator> xBreak = vcl::unohelper::CreateBreakIterator();
+            if (!mxBreak.is())
+                mxBreak = vcl::unohelper::CreateBreakIterator();
             com::sun::star::lang::Locale aLocale(rArgs.maLanguageTag.getLocale());
 
             for (int i = 0; i < nRunGlyphCount; ++i) {
@@ -539,13 +541,13 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
                 if(bRightToLeft && (nCharPos < nGraphemeStartPos))
                 {
                     sal_Int32 nDone;
-                    nGraphemeStartPos = xBreak->previousCharacters(rArgs.mrStr, nCharPos+1, aLocale,
+                    nGraphemeStartPos = mxBreak->previousCharacters(rArgs.mrStr, nCharPos+1, aLocale,
                                                   com::sun::star::i18n::CharacterIteratorMode::SKIPCELL, 1, nDone);
                 }
                 else if(!bRightToLeft && (nCharPos >= nGraphemeEndPos))
                 {
                     sal_Int32 nDone;
-                    nGraphemeEndPos = xBreak->nextCharacters(rArgs.mrStr, nCharPos, aLocale,
+                    nGraphemeEndPos = mxBreak->nextCharacters(rArgs.mrStr, nCharPos, aLocale,
                                                   com::sun::star::i18n::CharacterIteratorMode::SKIPCELL, 1, nDone);
                 }
                 else


More information about the Libreoffice-commits mailing list