mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-12 02:31:41 +00:00
Bug 815473 - Replace runtime computed gUnicodeToGBKTable by constants. r=smontagu
This commit is contained in:
parent
c31a587835
commit
8b51d4f17e
2684
intl/uconv/ucvcn/cp936invmap.h
Normal file
2684
intl/uconv/ucvcn/cp936invmap.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -11,17 +11,17 @@
|
||||
// nsGBKConvUtil
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
static bool gInitToGBKTable = false;
|
||||
static const PRUnichar gGBKToUnicodeTable[MAX_GBK_LENGTH] = {
|
||||
#include "cp936map.h"
|
||||
};
|
||||
static uint16_t gUnicodeToGBKTable[0xA000-0x4e00];
|
||||
static const uint16_t gUnicodeToGBKTable[0xA000-0x4e00] = {
|
||||
#include "cp936invmap.h"
|
||||
};
|
||||
|
||||
bool nsGBKConvUtil::UnicodeToGBKChar(
|
||||
PRUnichar aChar, bool aToGL, char*
|
||||
aOutByte1, char* aOutByte2)
|
||||
{
|
||||
NS_ASSERTION(gInitToGBKTable, "gGBKToUnicodeTable is not init yet. need to call InitToGBKTable first");
|
||||
bool found=false;
|
||||
*aOutByte1 = *aOutByte2 = 0;
|
||||
if(UNICHAR_IN_RANGE(0xd800, aChar, 0xdfff))
|
||||
@ -91,28 +91,3 @@ PRUnichar nsGBKConvUtil::GBKCharToUnicode(char aByte1, char aByte2)
|
||||
else
|
||||
return UCS2_NO_MAPPING;
|
||||
}
|
||||
void nsGBKConvUtil::InitToGBKTable()
|
||||
{
|
||||
if ( gInitToGBKTable )
|
||||
return;
|
||||
|
||||
PRUnichar unicode;
|
||||
PRUnichar i;
|
||||
// zap it to zero first
|
||||
memset(gUnicodeToGBKTable,0, sizeof(gUnicodeToGBKTable));
|
||||
|
||||
for ( i=0; i<MAX_GBK_LENGTH; i++ )
|
||||
{
|
||||
unicode = gGBKToUnicodeTable[i];
|
||||
// to reduce size of gUnicodeToGBKTable, we only do direct unicode to GB
|
||||
// table mapping between unicode 0x4E00 and 0xA000. Others by searching
|
||||
// gGBKToUnicodeTable. There is a trade off between memory usage and speed.
|
||||
if(UNICHAR_IN_RANGE(0x4e00, unicode, 0x9fff))
|
||||
{
|
||||
unicode -= 0x4E00;
|
||||
gUnicodeToGBKTable[unicode] = (( i / 0x00BF + 0x0081) << 8) |
|
||||
( i % 0x00BF+ 0x0040);
|
||||
}
|
||||
}
|
||||
gInitToGBKTable = true;
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ class nsGBKConvUtil {
|
||||
public:
|
||||
nsGBKConvUtil() { }
|
||||
~nsGBKConvUtil() { }
|
||||
void InitToGBKTable();
|
||||
PRUnichar GBKCharToUnicode(char aByte1, char aByte2);
|
||||
bool UnicodeToGBKChar(PRUnichar aChar, bool aToGL,
|
||||
char* aOutByte1, char* aOutByte2);
|
||||
|
@ -12,7 +12,6 @@
|
||||
nsUnicodeToGB2312V2::nsUnicodeToGB2312V2() :
|
||||
nsEncoderSupport(2)
|
||||
{
|
||||
mUtil.InitToGBKTable();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsUnicodeToGB2312V2::ConvertNoBuff(const PRUnichar * aSrc,
|
||||
|
@ -113,7 +113,6 @@ nsUnicodeToGBK::nsUnicodeToGBK(uint32_t aMaxLength) :
|
||||
{
|
||||
mExtensionEncoder = nullptr;
|
||||
m4BytesEncoder = nullptr;
|
||||
mUtil.InitToGBKTable();
|
||||
mSurrogateHigh = 0;
|
||||
}
|
||||
void nsUnicodeToGBK::CreateExtensionEncoder()
|
||||
|
@ -27,7 +27,6 @@
|
||||
#define UNICODE_TILD 0x007E
|
||||
nsUnicodeToHZ::nsUnicodeToHZ() : nsEncoderSupport(6)
|
||||
{
|
||||
mUtil.InitToGBKTable();
|
||||
mHZState = HZ_STATE_ASCII; // per HZ spec, default to HZ mode
|
||||
}
|
||||
NS_IMETHODIMP nsUnicodeToHZ::ConvertNoBuff(
|
||||
|
Loading…
x
Reference in New Issue
Block a user