[Libreoffice-commits] core.git: 2 commits - comphelper/source connectivity/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Wed Aug 7 18:13:28 UTC 2019


 comphelper/source/misc/string.cxx     |   16 +++++++++++-----
 connectivity/source/parse/sqlbison.y  |    1 +
 connectivity/source/parse/sqlnode.cxx |    1 +
 3 files changed, 13 insertions(+), 5 deletions(-)

New commits:
commit 6d024a69164716f7856ec936a72d01a6630d2a7c
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Aug 7 13:43:54 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Aug 7 20:12:52 2019 +0200

    tdf#126588 crash in saving view
    
    regression from
        commit d425658bd9fd8e315e4931afb544bc845da0360e
        Date:   Wed Dec 19 16:10:51 2018 +0200
        pass OSQLParseNode around by unique_ptr
    
    We have a OSQLNode being deleted at
    connectivity::OSQLParseNodesContainer::clearAndDelete() at
    connectivity/source/parse/sqlnode.cxx:2781
    connectivity::OSQLParser::parseTree(rtl::OUString&, rtl::OUString
    const&, bool)
    (this=0x38eba90, rErrorMessage="syntax error, unexpected UNION,
    expecting $end", rStatement="CREATE VIEW \"View1\" AS SELECT
    \"Tab1\".\"Name\" AS \"Name1\", \"Tab1\".\"Geburtsdatum\" AS
    \"Geburtsdatum1\", 1 AS \"MonatZahl1\",
    COALESCE(\"Tab1\".\"MonatZaehler\",999) AS \"MonatZaehler1\", 'Januar'
    AS \"Monat1\", \"Tab2"..., bInternational=false)
        at workdir/YaccTarget/connectivity/source/parse/sqlbison.cxx:10914
    namespace)::parseStatement_throwError(connectivity::OSQLParser&,
    rtl::OUString const&,
    com::sun::star::uno::Reference<com::sun::star::uno::XInterface> const&)
    (_rParser=..., _rStatement="CREATE VIEW \"View1\" AS SELECT
    \"Tab1\".\"Name\" AS \"Name1\", \"Tab1\".\"Geburtsdatum\" AS
    \"Geburtsdatum1\", 1 AS \"MonatZahl1\",
    COALESCE(\"Tab1\".\"MonatZaehler\",999) AS \"MonatZaehler1\", 'Januar'
    AS \"Monat1\", \"Tab2"..., _rxContext=uno::Reference to
    (dbaccess::OSingleSelectQueryComposer *) 0x38eb8d0)
        at dbaccess/source/core/api/SingleSelectQueryComposer.cxx:106
    
    and then again at
    std::unique_ptr<connectivity::OSQLParseNode,
    std::default_delete<connectivity::OSQLParseNode>
    >::operator=(decltype(nullptr))
    (this=0x38eba90) at connectivity/source/parse/sqlnode.cxx:1500
    
    Change-Id: I292627a06369208e0010743063c7eb5a38921a19
    Reviewed-on: https://gerrit.libreoffice.org/77106
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y
index 013073b882d5..a6aa13353584 100644
--- a/connectivity/source/parse/sqlbison.y
+++ b/connectivity/source/parse/sqlbison.y
@@ -4597,6 +4597,7 @@ std::unique_ptr<OSQLParseNode> OSQLParser::parseTree(OUString& rErrorMessage,
 
 		// clear the garbage collector
 		(*s_pGarbageCollector)->clearAndDelete();
+		m_pParseTree.release(); // because the garbage collector deleted it
 		return nullptr;
 	}
 	else
diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx
index 84bc3492ce90..3050d347fcdc 100644
--- a/connectivity/source/parse/sqlnode.cxx
+++ b/connectivity/source/parse/sqlnode.cxx
@@ -1293,6 +1293,7 @@ std::unique_ptr<OSQLParseNode> OSQLParser::predicateTree(OUString& rErrorMessage
 
         // clear the garbage collector
         (*s_pGarbageCollector)->clearAndDelete();
+        m_pParseTree.release(); // because the garbage collector deleted it
         return nullptr;
     }
     else
commit 66661417ff019831cbe7e647be2df1a4328ec2e6
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Aug 7 12:49:31 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Aug 7 20:12:40 2019 +0200

    tdf#126663 speed up styles display
    
    reduce temporary OUString creation in a hotspot, reduces the time for me
    from 9s to 1s
    
    Change-Id: I0d5c479f124361661d55e78b802c04a06a3fefae
    Reviewed-on: https://gerrit.libreoffice.org/77098
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/comphelper/source/misc/string.cxx b/comphelper/source/misc/string.cxx
index 98fc3d8585a7..31c8c750e8d8 100644
--- a/comphelper/source/misc/string.cxx
+++ b/comphelper/source/misc/string.cxx
@@ -143,11 +143,11 @@ sal_Int32 getTokenCount(const OUString &rIn, sal_Unicode cTok)
     return tmpl_getTokenCount<OUString, sal_Unicode>(rIn, cTok);
 }
 
-sal_uInt32 decimalStringToNumber(
-    OUString const & str )
+static sal_uInt32 decimalStringToNumber(
+    OUString const & str, sal_Int32 nStart, sal_Int32 nLength )
 {
     sal_uInt32 result = 0;
-    for( sal_Int32 i = 0 ; i < str.getLength() ; )
+    for( sal_Int32 i = nStart; i < nStart + nLength; )
     {
         sal_uInt32 c = str.iterateCodePoints(&i);
         sal_uInt32 value = 0;
@@ -240,6 +240,12 @@ sal_uInt32 decimalStringToNumber(
     return result;
 }
 
+sal_uInt32 decimalStringToNumber(
+    OUString const & str )
+{
+    return decimalStringToNumber(str, 0, str.getLength());
+}
+
 using namespace ::com::sun::star;
 
 // convert between sequence of string and comma separated string
@@ -342,8 +348,8 @@ sal_Int32 compareNatural( const OUString & rLHS, const OUString & rRHS,
         //numbers outside of the normal 0-9 range, e.g. see GetLocalizedChar in
         //vcl
 
-        sal_uInt32 nLHS = comphelper::string::decimalStringToNumber(rLHS.copy(nLHSFirstDigitPos, nLHSChunkLen));
-        sal_uInt32 nRHS = comphelper::string::decimalStringToNumber(rRHS.copy(nRHSFirstDigitPos, nRHSChunkLen));
+        sal_uInt32 nLHS = comphelper::string::decimalStringToNumber(rLHS, nLHSFirstDigitPos, nLHSChunkLen);
+        sal_uInt32 nRHS = comphelper::string::decimalStringToNumber(rRHS, nRHSFirstDigitPos, nRHSChunkLen);
 
         if (nLHS != nRHS)
         {


More information about the Libreoffice-commits mailing list