summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2013-04-22 15:17:59 +0200
committerTor Lillqvist <tlillqvist@suse.com>2013-04-25 16:16:45 +0300
commit31fb9b273bd9255dc5ff78d856e717751e4d3e92 (patch)
tree3a915b8bd8cb205e889eddedb53cecdc34973a70 /xmloff
parent3acaa6748d569acfd69b8f2ac22d35d168861c11 (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 425673213fc4..9ada1b73e46c 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -3175,17 +3175,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!" );