[Libreoffice-commits] core.git: 4 commits - connectivity/source i18npool/source vcl/generic vcl/source

Michael Stahl mstahl at redhat.com
Wed Feb 25 15:12:50 PST 2015


 connectivity/source/drivers/calc/CResultSet.cxx         |    2 +-
 connectivity/source/drivers/dbase/DResultSet.cxx        |    8 +++-----
 connectivity/source/drivers/flat/EResultSet.cxx         |    2 +-
 connectivity/source/drivers/mork/MResultSet.cxx         |    8 +++++---
 connectivity/source/drivers/mozab/MResultSet.cxx        |    8 +++++---
 i18npool/source/transliteration/transliterationImpl.cxx |   10 +++++++++-
 vcl/generic/glyphs/gcach_layout.cxx                     |    2 +-
 vcl/source/fontsubset/ttcr.cxx                          |   12 +++++++-----
 8 files changed, 32 insertions(+), 20 deletions(-)

New commits:
commit 7fde44c85620f8079bc4863fe3f7ea1f69a0f88c
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Feb 24 21:32:54 2015 +0100

    tdf#89666: vcl: speed up HbLayoutEngine line layout for large paragraphs
    
    When formatting a 180k char Writer paragraph, most of the time is spent
    in vcl::ScriptRun::next(), which is called twice per line from
    SwTxtGuess::Guess(), once via GetTxtBreak() and once via GetTxtSize().
    
    In the second call, from GetTxtSize(), the end position of the line is
    known, and passed to vcl, and iterating beyond that position seems
    pointless.
    
    This reduces vcl::ScriptRun::next() from 24 to 11 billion callgrind
    cycles when built with GCC 4.9.2 -m32 -Os.
    
    Change-Id: Ia23fcccaf5ef9c9ecdcb54bfc8f0f8a043c8711e

diff --git a/vcl/generic/glyphs/gcach_layout.cxx b/vcl/generic/glyphs/gcach_layout.cxx
index c6dfd48..5010423c 100644
--- a/vcl/generic/glyphs/gcach_layout.cxx
+++ b/vcl/generic/glyphs/gcach_layout.cxx
@@ -370,7 +370,7 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
 
     rLayout.Reserve(nGlyphCapacity);
 
-    vcl::ScriptRun aScriptRun(reinterpret_cast<const UChar *>(rArgs.mpStr), rArgs.mnLength);
+    vcl::ScriptRun aScriptRun(reinterpret_cast<const UChar *>(rArgs.mpStr), rArgs.mnEndCharPos);
 
     Point aCurrPos(0, 0);
     while (true)
commit 88d4b2fb08b983531b1e0abc71b07f4bdecdc925
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Feb 20 20:57:59 2015 +0100

    tdf#89665: i18npool: fix pathological transliterate slow-path
    
    TransliterationImpl::transliterate() has a slow-path for the case when
    more than one trasliteration module is cascaded which swaps 2
    uno::Sequence.  This is unbelievably slow because non-const
    Sequence::operator[] does a function call into cppu to check whether COW
    has to be done.
    
    This speeds up transliterate() from 344 billion to 101 billion callgrind
    cycles when built with GCC 4.9.2 -m32 -Os.
    
    Commit d2771b63b94a8aae3c25c83e9dae9f83242f46c1 added a second
    transliteration module that is enabled by default, making the problem
    visible, especially with long paragraphs in Writer.
    
    Change-Id: I2799df9173ac73aab8c4eb4cc6f592976b06c8da

diff --git a/i18npool/source/transliteration/transliterationImpl.cxx b/i18npool/source/transliteration/transliterationImpl.cxx
index a90ef47..f780b6e 100644
--- a/i18npool/source/transliteration/transliterationImpl.cxx
+++ b/i18npool/source/transliteration/transliterationImpl.cxx
@@ -326,9 +326,17 @@ TransliterationImpl::transliterate( const OUString& inStr, sal_Int32 startPos, s
 
             nCount = tmpStr.getLength();
 
+            assert(off[from].getLength() == nCount);
             tmp = from; from = to; to = tmp;
+            // tdf#89665: don't use operator[] to write - too slow!
+            // interestingly gcc 4.9 -Os won't even inline the const operator[]
+            sal_Int32 const*const pFrom(off[from].getConstArray());
+            sal_Int32 *const pTo(off[to].getArray());
             for (sal_Int32 j = 0; j < nCount; j++)
-                off[to][j] = off[from][off[to][j]];
+            {
+                assert(pTo[j] < off[from].getLength());
+                pTo[j] = pFrom[pTo[j]];
+            }
         }
         offset = off[to];
         return tmpStr;
commit b825167228b016e77435246fb4bf1e2bd184311f
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Feb 19 16:55:04 2015 +0100

    vcl: these compare functions use subtraction and could overflow
    
    Change-Id: I84c7a4cde694395fa70c60edffd63fb45ffcb3a8

diff --git a/vcl/source/fontsubset/ttcr.cxx b/vcl/source/fontsubset/ttcr.cxx
index 25c66d1..5e54061e 100644
--- a/vcl/source/fontsubset/ttcr.cxx
+++ b/vcl/source/fontsubset/ttcr.cxx
@@ -148,7 +148,9 @@ _inline void PutUInt32(sal_uInt32 val, sal_uInt8 *ptr, sal_uInt32 offset, int bi
 
 static int TableEntryCompareF(const void *l, const void *r)
 {
-    return ((const TableEntry *) l)->tag - ((const TableEntry *) r)->tag;
+    sal_uInt32 const ltag(static_cast<TableEntry const*>(l)->tag);
+    sal_uInt32 const rtag(static_cast<TableEntry const*>(r)->tag);
+    return (ltag == rtag) ? 0 : (ltag < rtag) ? -1 : 1;
 }
 
 static int NameRecordCompareF(const void *l, const void *r)
@@ -157,13 +159,13 @@ static int NameRecordCompareF(const void *l, const void *r)
     NameRecord *rr = (NameRecord *) r;
 
     if (ll->platformID != rr->platformID) {
-        return ll->platformID - rr->platformID;
+        return (ll->platformID < rr->platformID) ? -1 : 1;
     } else if (ll->encodingID != rr->encodingID) {
-        return ll->encodingID - rr->encodingID;
+        return (ll->encodingID < rr->encodingID) ? -1 : 1;
     } else if (ll->languageID != rr->languageID) {
-        return ll->languageID - rr->languageID;
+        return (ll->languageID < rr->languageID) ? -1 : 1;
     } else if (ll->nameID != rr->nameID) {
-        return ll->nameID - rr->nameID;
+        return (ll->nameID < rr->nameID) ? -1 : 1;
     }
     return 0;
 }
commit 250ef02bd80e15bdc7fe86ba149b8c838b363114
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Feb 19 15:22:05 2015 +0100

    connectivity: replace magic numbers with constants from CompareBookmark
    
    Change-Id: Ifcd5766ce10de44f38d5c383cd7dc35b75152e88

diff --git a/connectivity/source/drivers/calc/CResultSet.cxx b/connectivity/source/drivers/calc/CResultSet.cxx
index 236c170..25f810e 100644
--- a/connectivity/source/drivers/calc/CResultSet.cxx
+++ b/connectivity/source/drivers/calc/CResultSet.cxx
@@ -110,7 +110,7 @@ sal_Bool SAL_CALL OCalcResultSet::moveRelativeToBookmark( const  Any& bookmark,
 
 sal_Int32 SAL_CALL OCalcResultSet::compareBookmarks( const Any& lhs, const  Any& rhs ) throw( SQLException,  RuntimeException, std::exception)
 {
-    return (lhs == rhs) ? 0 : 2;
+    return (lhs == rhs) ? CompareBookmark::EQUAL : CompareBookmark::NOT_EQUAL;
 }
 
 sal_Bool SAL_CALL OCalcResultSet::hasOrderedBookmarks(  ) throw( SQLException,  RuntimeException, std::exception)
diff --git a/connectivity/source/drivers/dbase/DResultSet.cxx b/connectivity/source/drivers/dbase/DResultSet.cxx
index 148b6ba..af7e9b9 100644
--- a/connectivity/source/drivers/dbase/DResultSet.cxx
+++ b/connectivity/source/drivers/dbase/DResultSet.cxx
@@ -122,14 +122,12 @@ sal_Int32 SAL_CALL ODbaseResultSet::compareBookmarks( const Any& lhs, const Any&
         ::dbtools::throwGenericSQLException(sMessage ,*this);
     } // if ( !( lhs  >>= nFirst ) || !( rhs >>= nSecond ) )
 
-    // have a look at CompareBookmark
-    // we can't use the names there because we already have defines with the same name from the parser
     if(nFirst < nSecond)
-        nResult = -1;
+        nResult = CompareBookmark::LESS;
     else if(nFirst > nSecond)
-        nResult = 1;
+        nResult = CompareBookmark::GREATER;
     else
-        nResult = 0;
+        nResult = CompareBookmark::EQUAL;
 
     return  nResult;
 }
diff --git a/connectivity/source/drivers/flat/EResultSet.cxx b/connectivity/source/drivers/flat/EResultSet.cxx
index 84a3a07..1501766 100644
--- a/connectivity/source/drivers/flat/EResultSet.cxx
+++ b/connectivity/source/drivers/flat/EResultSet.cxx
@@ -129,7 +129,7 @@ sal_Bool SAL_CALL OFlatResultSet::moveRelativeToBookmark( const  Any& bookmark,
 
 sal_Int32 SAL_CALL OFlatResultSet::compareBookmarks( const Any& lhs, const  Any& rhs ) throw( SQLException,  RuntimeException, std::exception)
 {
-    return (lhs == rhs) ? 0 : 2;
+    return (lhs == rhs) ? CompareBookmark::EQUAL : CompareBookmark::NOT_EQUAL;
 }
 
 sal_Bool SAL_CALL OFlatResultSet::hasOrderedBookmarks(  ) throw( SQLException,  RuntimeException, std::exception)
diff --git a/connectivity/source/drivers/mork/MResultSet.cxx b/connectivity/source/drivers/mork/MResultSet.cxx
index e9817f0..1b355cb 100644
--- a/connectivity/source/drivers/mork/MResultSet.cxx
+++ b/connectivity/source/drivers/mork/MResultSet.cxx
@@ -28,6 +28,7 @@
 #include <com/sun/star/sdbc/ResultSetType.hpp>
 #include <com/sun/star/sdbc/FetchDirection.hpp>
 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbcx/CompareBookmark.hpp>
 #include <comphelper/types.hxx>
 #include <connectivity/dbexception.hxx>
 #include <connectivity/dbtools.hxx>
@@ -57,6 +58,7 @@ using namespace com::sun::star::uno;
 using namespace com::sun::star::lang;
 using namespace com::sun::star::beans;
 using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
 using namespace com::sun::star::container;
 using namespace com::sun::star::io;
 using namespace com::sun::star::util;
@@ -1610,11 +1612,11 @@ sal_Int32 OResultSet::compareBookmarks( const ::com::sun::star::uno::Any& lhs, c
         }
 
     if(nFirst < nSecond)
-         nResult = -1;
+        nResult = CompareBookmark::LESS;
     else if(nFirst > nSecond)
-         nResult = 1;
+        nResult = CompareBookmark::GREATER;
     else
-         nResult = 0;
+        nResult = CompareBookmark::EQUAL;
 
     return  nResult;
 }
diff --git a/connectivity/source/drivers/mozab/MResultSet.cxx b/connectivity/source/drivers/mozab/MResultSet.cxx
index 11c6a4b..77474f8 100644
--- a/connectivity/source/drivers/mozab/MResultSet.cxx
+++ b/connectivity/source/drivers/mozab/MResultSet.cxx
@@ -28,6 +28,7 @@
 #include <com/sun/star/sdbc/ResultSetType.hpp>
 #include <com/sun/star/sdbc/FetchDirection.hpp>
 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbcx/CompareBookmark.hpp>
 #include <comphelper/types.hxx>
 #include <connectivity/dbexception.hxx>
 #include <connectivity/dbtools.hxx>
@@ -56,6 +57,7 @@ using namespace com::sun::star::uno;
 using namespace com::sun::star::lang;
 using namespace com::sun::star::beans;
 using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
 using namespace com::sun::star::container;
 using namespace com::sun::star::io;
 using namespace com::sun::star::util;
@@ -1619,11 +1621,11 @@ sal_Int32 OResultSet::compareBookmarks( const ::com::sun::star::uno::Any& lhs, c
         m_pStatement->getOwnConnection()->throwSQLException( STR_INVALID_BOOKMARK, *this );
 
     if(nFirst < nSecond)
-         nResult = -1;
+        nResult = CompareBookmark::LESS;
     else if(nFirst > nSecond)
-         nResult = 1;
+        nResult = CompareBookmark::GREATER;
     else
-         nResult = 0;
+        nResult = CompareBookmark::EQUAL;
 
     return  nResult;
 }


More information about the Libreoffice-commits mailing list