summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2013-04-22 15:17:59 +0200
committerMichael Stahl <mstahl@redhat.com>2013-04-22 15:21:57 +0200
commitaa64fd12d62f78ab007b3a7b30f637b6b5fef9ff (patch)
tree773c504425440067546489ad0fd5c1f3a6748150 /xmloff
parent784554dece1afd1008a765144a9d45bea7ee1760 (diff)
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
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/core/xmltoken.cxx26
1 files changed, 16 insertions, 10 deletions
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 7c6d110b2e9c..2dfbe312a819 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!" );