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

Michael Stahl mstahl at redhat.com
Mon Apr 22 06:24:32 PDT 2013


 xmloff/source/core/xmltoken.cxx |   26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

New commits:
commit aa64fd12d62f78ab007b3a7b30f637b6b5fef9ff
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Apr 22 15:17:59 2013 +0200

    xmloff::token::GetXMLToken: only execute the check once
    
    Tor says this check eats many CPU cycles, and the checked array is
    static, so checking it just once is sufficient.
    
    Change-Id: Ic8f85ebe940e4cf2c258cc778a8fd14512bdef94

diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 7c6d110..2dfbe31 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -3197,17 +3197,23 @@ namespace xmloff { namespace token {
     const OUString& GetXMLToken( enum XMLTokenEnum eToken )
     {
 #if OSL_DEBUG_LEVEL > 0
-        // check the consistency of the token list. Below, we use the ordinal value of
-        // the token as index into the token list, so we should make sure that every
-        // entry is at the proper position
-        const XMLTokenEntry* pEntry = aTokenList;
-        const XMLTokenEntry* pEntryEnd = pEntry + sizeof ( aTokenList ) / sizeof ( XMLTokenEntry );
-        sal_uInt16 nPos = 0;
-        while ( pEntry < pEntryEnd )
+        static bool s_bChecked = false;
+        if (!s_bChecked)
         {
-            assert(nPos == static_cast<sal_uInt16>(pEntry->eToken));
-                // "xmloff::GetXMLToken: inconsistency in the token list!"
-            ++pEntry, ++nPos;
+            // check the consistency of the token list. Below, we use the
+            // ordinal value of the token as index into the token list, so we
+            // should make sure that every entry is at the proper position
+            const XMLTokenEntry* pEntry = aTokenList;
+            const XMLTokenEntry* pEntryEnd =
+                pEntry + SAL_N_ELEMENTS(aTokenList);
+            sal_uInt16 nPos = 0;
+            while (pEntry < pEntryEnd)
+            {
+                assert(nPos == static_cast<sal_uInt16>(pEntry->eToken));
+                    // "xmloff::GetXMLToken: inconsistency in the token list!"
+                ++pEntry, ++nPos;
+            }
+            s_bChecked = true; // it's all static, checking once is enough
         }
 #endif
         DBG_ASSERT( eToken > XML_TOKEN_INVALID, "token value too low!" );
commit 784554dece1afd1008a765144a9d45bea7ee1760
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Apr 22 15:13:40 2013 +0200

    xmloff::token::GetXMLToken: deploy assert in consistency check
    
    There will be serious problems if that is inconsistent.
    
    Change-Id: I41b8de66132224fb5cd2a6dcb7ff3128eb704016

diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 264770d..7c6d110 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -3205,8 +3205,8 @@ namespace xmloff { namespace token {
         sal_uInt16 nPos = 0;
         while ( pEntry < pEntryEnd )
         {
-            OSL_ENSURE( nPos == (sal_uInt16)(pEntry->eToken),
-                "xmloff::GetXMLToken: inconsistency in the token list!" );
+            assert(nPos == static_cast<sal_uInt16>(pEntry->eToken));
+                // "xmloff::GetXMLToken: inconsistency in the token list!"
             ++pEntry, ++nPos;
         }
 #endif


More information about the Libreoffice-commits mailing list