From 8512e5c2b3617a2c8d77381788c3864db594ce46 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 16 May 2012 11:19:17 +0100 Subject: reduce static_initialization_and_destruction chain Change-Id: I962aeac0c7feeabb7963016d5afcfeca5a48ccfe --- svtools/source/edit/syntaxhighlight.cxx | 47 ++++++++++++++------------------- 1 file changed, 20 insertions(+), 27 deletions(-) (limited to 'svtools') diff --git a/svtools/source/edit/syntaxhighlight.cxx b/svtools/source/edit/syntaxhighlight.cxx index d4caa88c511f..2bf3d0204a7e 100644 --- a/svtools/source/edit/syntaxhighlight.cxx +++ b/svtools/source/edit/syntaxhighlight.cxx @@ -234,39 +234,32 @@ extern "C" int CDECL compare_strings( const void *arg1, const void *arg2 ) } -namespace { - -class LetterTable +namespace { - bool IsLetterTab[256]; - -public: - LetterTable( void ); - inline bool isLetter( sal_Unicode c ) + class LetterTable { - bool bRet = (c < 256) ? IsLetterTab[c] : isLetterUnicode( c ); - return bRet; - } - bool isLetterUnicode( sal_Unicode c ); -}; + bool IsLetterTab[256]; -} + public: + LetterTable( void ); -class BasicSimpleCharClass -{ - static LetterTable aLetterTable; + inline bool isLetter( sal_Unicode c ) + { + bool bRet = (c < 256) ? IsLetterTab[c] : isLetterUnicode( c ); + return bRet; + } + bool isLetterUnicode( sal_Unicode c ); + }; -public: - static sal_Bool isAlpha( sal_Unicode c ) + static bool isAlpha(sal_Unicode c) { - sal_Bool bRet = comphelper::string::isalphaAscii(c) || - aLetterTable.isLetter(c); - return bRet; + if (comphelper::string::isalphaAscii(c)) + return true; + static LetterTable aLetterTable; + return aLetterTable.isLetter(c); } -}; - -LetterTable BasicSimpleCharClass::aLetterTable; +} LetterTable::LetterTable( void ) { @@ -358,7 +351,7 @@ sal_Bool SimpleTokenizer_Impl::testCharFlags( sal_Unicode c, sal_uInt16 nTestFla else if( c > 255 ) { bRet = (( CHAR_START_IDENTIFIER | CHAR_IN_IDENTIFIER ) & nTestFlags) != 0 - ? BasicSimpleCharClass::isAlpha(c) : false; + ? isAlpha(c) : false; } return bRet; } @@ -469,7 +462,7 @@ sal_Bool SimpleTokenizer_Impl::getNextToken( /*out*/TokenTypes& reType, { // Naechstes Zeichen holen c = peekChar(); - bIdentifierChar = BasicSimpleCharClass::isAlpha(c); + bIdentifierChar = isAlpha(c); if( bIdentifierChar ) getChar(); } -- cgit v1.2.3