[Libreoffice-commits] core.git: Branch 'private/kohei/xlsx-import-speedup' - include/oox include/sax oox/source sax/source sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Thu Nov 21 18:47:43 PST 2013


Rebased ref, commits from common ancestor:
commit c5ed10034a7a735029829b4e7196f7395056aec6
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Thu Nov 21 20:32:46 2013 -0500

    getChar() to return a null-terminated char array.
    
    No need to fetch string size with this change.
    
    Change-Id: Iae5f6c60430fc57985a0fec5bfec59727e5a8f0f

diff --git a/include/oox/helper/attributelist.hxx b/include/oox/helper/attributelist.hxx
index 78ea83e..e22e816 100644
--- a/include/oox/helper/attributelist.hxx
+++ b/include/oox/helper/attributelist.hxx
@@ -75,12 +75,6 @@ public:
 class OOX_DLLPUBLIC AttributeList
 {
 public:
-    struct Char
-    {
-        const char* mpPos;
-        size_t mnSize;
-    };
-
     explicit            AttributeList(
                             const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs );
 
@@ -138,7 +132,7 @@ public:
         passed default string if the attribute is missing. */
     OUString     getXString( sal_Int32 nAttrToken, const OUString& rDefault ) const;
 
-    Char getChar( sal_Int32 nAttrToken ) const;
+    const char* getChar( sal_Int32 nAttrToken ) const;
 
 
     /** Returns the double value of the specified attribute, or the passed
diff --git a/include/sax/fastattribs.hxx b/include/sax/fastattribs.hxx
index f47da07..42b285c 100644
--- a/include/sax/fastattribs.hxx
+++ b/include/sax/fastattribs.hxx
@@ -76,7 +76,7 @@ public:
     // performance sensitive shortcuts to avoid allocation ...
     bool getAsInteger( sal_Int32 nToken, sal_Int32 &rInt);
     bool getAsDouble( sal_Int32 nToken, double &rDouble);
-    bool getAsChar( sal_Int32 nToken, const char*& rPos, size_t& rLen ) const;
+    bool getAsChar( sal_Int32 nToken, const char*& rPos ) const;
 
     // XFastAttributeList
     virtual ::sal_Bool SAL_CALL hasAttribute( ::sal_Int32 Token ) throw (::com::sun::star::uno::RuntimeException);
diff --git a/oox/source/helper/attributelist.cxx b/oox/source/helper/attributelist.cxx
index e57dd1d..2efc3a3 100644
--- a/oox/source/helper/attributelist.cxx
+++ b/oox/source/helper/attributelist.cxx
@@ -261,16 +261,14 @@ OUString AttributeList::getXString( sal_Int32 nAttrToken, const OUString& rDefau
     return getXString( nAttrToken ).get( rDefault );
 }
 
-AttributeList::Char AttributeList::getChar( sal_Int32 nAttrToken ) const
+const char* AttributeList::getChar( sal_Int32 nAttrToken ) const
 {
-    Char aRet;
-    bool bValid = getAttribList()->getAsChar(nAttrToken, aRet.mpPos, aRet.mnSize);
+    const char* p = NULL;
+    bool bValid = getAttribList()->getAsChar(nAttrToken, p);
     if (!bValid)
-    {
-        aRet.mpPos = NULL;
-        aRet.mnSize = 0;
-    }
-    return aRet;
+        p = NULL;
+
+    return p;
 }
 
 double AttributeList::getDouble( sal_Int32 nAttrToken, double fDefault ) const
diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx
index 17b9a3f..ee65cc6 100644
--- a/sax/source/tools/fastattribs.cxx
+++ b/sax/source/tools/fastattribs.cxx
@@ -157,7 +157,7 @@ bool FastAttributeList::getAsDouble( sal_Int32 nToken, double &rDouble)
     return false;
 }
 
-bool FastAttributeList::getAsChar( sal_Int32 nToken, const char*& rPos, size_t& rLen ) const
+bool FastAttributeList::getAsChar( sal_Int32 nToken, const char*& rPos ) const
 {
     for (size_t i = 0, n = maAttributeTokens.size(); i < n; ++i)
     {
@@ -166,12 +166,6 @@ bool FastAttributeList::getAsChar( sal_Int32 nToken, const char*& rPos, size_t&
 
         sal_Int32 nOffset = maAttributeValues[i];
         rPos = mpChunk + nOffset;
-
-        if (i + 1 < maAttributeValues.size())
-            rLen = maAttributeValues[i+1] - nOffset - 1;
-        else
-            rLen = mnChunkLength - nOffset - 1;
-
         return true;
     }
 
diff --git a/sc/source/filter/inc/addressconverter.hxx b/sc/source/filter/inc/addressconverter.hxx
index 886e074..36f8599 100644
--- a/sc/source/filter/inc/addressconverter.hxx
+++ b/sc/source/filter/inc/addressconverter.hxx
@@ -214,7 +214,7 @@ public:
                             sal_Int32 nLength = SAL_MAX_INT32 );
 
     static bool parseOoxAddress2d(
-        sal_Int32& ornColumn, sal_Int32& ornRow, const char* pStr, sal_Int32 nStrLen );
+        sal_Int32& ornColumn, sal_Int32& ornRow, const char* pStr );
 
     /** Tries to parse the passed string for a 2d cell range in A1 notation.
 
@@ -320,8 +320,7 @@ public:
                             sal_Int16 nSheet );
 
     bool convertToCellAddressUnchecked(
-        com::sun::star::table::CellAddress& orAddress,
-        const char* pStr, size_t nStrLen, sal_Int16 nSheet ) const;
+        com::sun::star::table::CellAddress& orAddress, const char* pStr, sal_Int16 nSheet ) const;
 
     /** Tries to convert the passed string to a single cell address.
 
@@ -340,7 +339,7 @@ public:
 
     bool convertToCellAddress(
         com::sun::star::table::CellAddress& rAddress,
-        const char* pStr, size_t nStrLen, sal_Int16 nSheet, bool bTrackOverflow );
+        const char* pStr, sal_Int16 nSheet, bool bTrackOverflow );
 
     /** Returns a valid cell address by moving it into allowed dimensions.
 
diff --git a/sc/source/filter/oox/addressconverter.cxx b/sc/source/filter/oox/addressconverter.cxx
index b9dbc53..59028ba 100644
--- a/sc/source/filter/oox/addressconverter.cxx
+++ b/sc/source/filter/oox/addressconverter.cxx
@@ -226,16 +226,13 @@ bool AddressConverter::parseOoxAddress2d(
     return (ornColumn >= 0) && (ornRow >= 0);
 }
 
-bool AddressConverter::parseOoxAddress2d(
-    sal_Int32& ornColumn, sal_Int32& ornRow, const char* pStr, sal_Int32 nStrLen )
+bool AddressConverter::parseOoxAddress2d( sal_Int32& ornColumn, sal_Int32& ornRow, const char* pStr )
 {
     ornColumn = ornRow = 0;
 
-    const char* pStrEnd = pStr + nStrLen;
-
     enum { STATE_COL, STATE_ROW } eState = STATE_COL;
 
-    while (pStr < pStrEnd)
+    while (*pStr)
     {
         char cChar = *pStr;
         switch( eState )
@@ -356,11 +353,10 @@ bool AddressConverter::convertToCellAddressUnchecked( CellAddress& orAddress,
 }
 
 bool AddressConverter::convertToCellAddressUnchecked(
-        com::sun::star::table::CellAddress& orAddress,
-        const char* pStr, size_t nStrLen, sal_Int16 nSheet ) const
+        com::sun::star::table::CellAddress& orAddress, const char* pStr, sal_Int16 nSheet ) const
 {
     orAddress.Sheet = nSheet;
-    return parseOoxAddress2d(orAddress.Column, orAddress.Row, pStr, nStrLen);
+    return parseOoxAddress2d(orAddress.Column, orAddress.Row, pStr);
 }
 
 bool AddressConverter::convertToCellAddress( CellAddress& orAddress,
@@ -373,9 +369,9 @@ bool AddressConverter::convertToCellAddress( CellAddress& orAddress,
 
 bool AddressConverter::convertToCellAddress(
     com::sun::star::table::CellAddress& rAddress,
-    const char* pStr, size_t nStrLen, sal_Int16 nSheet, bool bTrackOverflow )
+    const char* pStr, sal_Int16 nSheet, bool bTrackOverflow )
 {
-    if (!convertToCellAddressUnchecked(rAddress, pStr, nStrLen, nSheet))
+    if (!convertToCellAddressUnchecked(rAddress, pStr, nSheet))
         return false;
 
     return checkCellAddress(rAddress, bTrackOverflow);
diff --git a/sc/source/filter/oox/sheetdatacontext.cxx b/sc/source/filter/oox/sheetdatacontext.cxx
index ca55119..5170234 100644
--- a/sc/source/filter/oox/sheetdatacontext.cxx
+++ b/sc/source/filter/oox/sheetdatacontext.cxx
@@ -311,18 +311,16 @@ void SheetDataContext::importRow( const AttributeList& rAttribs )
 bool SheetDataContext::importCell( const AttributeList& rAttribs )
 {
     bool bValid = true;
-    AttributeList::Char aChar = rAttribs.getChar(XML_r);
+    const char* p = rAttribs.getChar(XML_r);
 
-    if (!aChar.mpPos)
+    if (!p)
     {
         ++mnCol;
         maCellData.maCellAddr = CellAddress( mnSheet, mnCol, mnRow );
     }
     else
     {
-        bValid = mrAddressConv.convertToCellAddress(
-            maCellData.maCellAddr, aChar.mpPos, aChar.mnSize, mnSheet, true);
-
+        bValid = mrAddressConv.convertToCellAddress(maCellData.maCellAddr, p, mnSheet, true);
         mnCol = maCellData.maCellAddr.Column;
     }
 


More information about the Libreoffice-commits mailing list