do bit compar before do string compare to imporve performance

This commit is contained in:
ftang%netscape.com 1999-06-08 21:12:20 +00:00
Родитель 5aed16123a
Коммит 063b816ac8
1 изменённых файлов: 38 добавлений и 34 удалений

Просмотреть файл

@ -134,20 +134,23 @@ void nsUnicodeFontMappingMac::InitByFontFamily(nsFont* aFont, nsIDeviceContext *
void nsUnicodeFontMappingMac::processOneLangRegion(const char* aLanguage, const char* aRegion ) void nsUnicodeFontMappingMac::processOneLangRegion(const char* aLanguage, const char* aRegion )
{ {
if(! nsCRT::strcmp(aLanguage,"zh")) { if(gUtil->ScriptEnabled(smTradChinese) &&
if((! nsCRT::strcmp(aRegion,"TW")) || (! nsCRT::strcmp(aRegion,"HK"))) { ((! nsCRT::strcmp(aLanguage,"zh")) &&
if(gUtil->ScriptEnabled(smTradChinese)) ((! nsCRT::strcmp(aRegion,"TW")) || (! nsCRT::strcmp(aRegion,"HK")))))
FillVarBlockToScript(smTradChinese, mPrivBlockToScript); {
} else { FillVarBlockToScript(smTradChinese, mPrivBlockToScript);
if(gUtil->ScriptEnabled(smSimpChinese)) }
FillVarBlockToScript(smSimpChinese, mPrivBlockToScript); else if(gUtil->ScriptEnabled(smSimpChinese) && (! nsCRT::strcmp(aLanguage,"zh")))
} {
} else if(! nsCRT::strcmp(aLanguage,"ko")) { FillVarBlockToScript(smSimpChinese, mPrivBlockToScript);
if(gUtil->ScriptEnabled(smKorean)) }
FillVarBlockToScript(smKorean, mPrivBlockToScript); else if(gUtil->ScriptEnabled(smKorean) && (! nsCRT::strcmp(aLanguage,"ko")))
} else if(! nsCRT::strcmp(aLanguage,"ja")) { {
if(gUtil->ScriptEnabled(smJapanese)) FillVarBlockToScript(smKorean, mPrivBlockToScript);
FillVarBlockToScript(smJapanese, mPrivBlockToScript); }
else if(gUtil->ScriptEnabled(smJapanese) && (! nsCRT::strcmp(aLanguage,"ja")))
{
FillVarBlockToScript(smJapanese, mPrivBlockToScript);
} }
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@ -207,8 +210,7 @@ void nsUnicodeFontMappingMac::InitByLANG(const nsString& aLANG)
case 2: case 2:
if(kComma == *p) { if(kComma == *p) {
processOneLangRegion(language, region); processOneLangRegion(language, region);
language[0]= language[1] = region[0]= region[1] = ' '; return;
state = 0;
} else if(kUnderline == *p) { } else if(kUnderline == *p) {
state = 3; state = 3;
} else { } else {
@ -227,8 +229,7 @@ void nsUnicodeFontMappingMac::InitByLANG(const nsString& aLANG)
case 5: case 5:
if(kComma == *p) { if(kComma == *p) {
processOneLangRegion(language, region); processOneLangRegion(language, region);
language[0]= language[1] = region[0]= region[1] = ' '; return;
state = 0;
} else { } else {
state = -1; state = -1;
} }
@ -245,28 +246,31 @@ void nsUnicodeFontMappingMac::InitByDocumentCharset(const nsString& aDocumentCha
// do not countinue if there are no difference to look at the document Charset // do not countinue if there are no difference to look at the document Charset
if( ScriptMapInitComplete() ) if( ScriptMapInitComplete() )
return; return;
if (aDocumentCharset.EqualsIgnoreCase("GB2312") || if(gUtil->ScriptEnabled(smRoman) && aDocumentCharset.EqualsIgnoreCase("ISO-8859-1"))
{
FillVarBlockToScript(smRoman, mPrivBlockToScript);
} else if(gUtil->ScriptEnabled(smSimpChinese) &&
(aDocumentCharset.EqualsIgnoreCase("GB2312") ||
aDocumentCharset.EqualsIgnoreCase("ISO-2022-CN") || aDocumentCharset.EqualsIgnoreCase("ISO-2022-CN") ||
aDocumentCharset.EqualsIgnoreCase("ZH") ) aDocumentCharset.EqualsIgnoreCase("ZH") ))
{ {
if(gUtil->ScriptEnabled(smSimpChinese)) FillVarBlockToScript(smSimpChinese, mPrivBlockToScript);
FillVarBlockToScript(smSimpChinese, mPrivBlockToScript); } else if(gUtil->ScriptEnabled(smKorean) &&
} else if( aDocumentCharset.EqualsIgnoreCase("EUC-KR") || ( aDocumentCharset.EqualsIgnoreCase("EUC-KR") ||
aDocumentCharset.EqualsIgnoreCase("ISO-2022-KR") ) aDocumentCharset.EqualsIgnoreCase("ISO-2022-KR") ))
{ {
if(gUtil->ScriptEnabled(smKorean)) FillVarBlockToScript(smKorean, mPrivBlockToScript);
FillVarBlockToScript(smKorean, mPrivBlockToScript); } else if(gUtil->ScriptEnabled(smTradChinese) &&
} else if( aDocumentCharset.EqualsIgnoreCase("Big5") || ( aDocumentCharset.EqualsIgnoreCase("Big5") ||
aDocumentCharset.EqualsIgnoreCase("x-euc-tw") ) aDocumentCharset.EqualsIgnoreCase("x-euc-tw") ))
{ {
if(gUtil->ScriptEnabled(smTradChinese)) FillVarBlockToScript(smTradChinese, mPrivBlockToScript);
FillVarBlockToScript(smTradChinese, mPrivBlockToScript); } else if(gUtil->ScriptEnabled(smJapanese) &&
} else if( aDocumentCharset.EqualsIgnoreCase("Shift_JIS") || ( aDocumentCharset.EqualsIgnoreCase("Shift_JIS") ||
aDocumentCharset.EqualsIgnoreCase("EUC-JP") || aDocumentCharset.EqualsIgnoreCase("EUC-JP") ||
aDocumentCharset.EqualsIgnoreCase("ISO-2022-JP") ) aDocumentCharset.EqualsIgnoreCase("ISO-2022-JP") ))
{ {
if(gUtil->ScriptEnabled(smJapanese)) FillVarBlockToScript(smJapanese, mPrivBlockToScript);
FillVarBlockToScript(smJapanese, mPrivBlockToScript);
} }
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------