ICU-868 Make openCCSID slightly faster when creating the alias.

X-SVN-Rev: 9027
This commit is contained in:
George Rhoten 2002-07-03 16:54:59 +00:00
parent 88868b845e
commit 1c36a6fe33
3 changed files with 18 additions and 20 deletions

View file

@ -104,7 +104,7 @@ ucnv_openU (const UChar * name,
return NULL;
if (name == NULL)
return ucnv_open (NULL, err);
if (u_strlen (name) > UCNV_MAX_CONVERTER_NAME_LENGTH)
if (u_strlen(name) > UCNV_MAX_CONVERTER_NAME_LENGTH)
{
*err = U_ILLEGAL_ARGUMENT_ERROR;
return NULL;
@ -125,13 +125,11 @@ ucnv_openCCSID (int32_t codepage,
if (U_FAILURE (*err))
return NULL;
ucnv_copyPlatformString (myName, platform);
myNameLen = uprv_strlen(myName);
myName[myNameLen++] = '-';
myName[myNameLen] = 0;
T_CString_integerToString (myName + myNameLen, codepage, 10);
/* ucnv_copyPlatformString could return "ibm-" or "cp" */
myNameLen = ucnv_copyPlatformString(myName, platform);
T_CString_integerToString(myName + myNameLen, codepage, 10);
return ucnv_createConverter (myName, err);
return ucnv_createConverter(myName, err);
}
/* Creating a temporary stack-based object that can be used in one thread,

View file

@ -185,24 +185,19 @@ static UConverterSharedData *createConverterFromFile (const char *fileName, UErr
return sharedData;
}
void
int32_t
ucnv_copyPlatformString(char *platformString, UConverterPlatform pltfrm)
{
switch (pltfrm)
{
case UCNV_IBM:
{
uprv_strcpy (platformString, "ibm");
break;
}
default:
{
uprv_strcpy (platformString, "");
break;
}
uprv_strcpy(platformString, "ibm-");
return 4;
};
return;
/* default to empty string */
*platformString = 0;
return 0;
}
/*returns a converter type from a string

View file

@ -57,7 +57,12 @@ UBool ucnv_deleteSharedConverterData (UConverterSharedData * sharedConverterData
*/
UBool ucnv_isDataBasedConverter (const char *name);
void ucnv_copyPlatformString (char *platformString, UConverterPlatform pltfrm);
/* Copy the string that is represented by the UConverterPlatform enum
* @param platformString An output buffer
* @param platform An enum representing a platform
* @return the length of the copied string.
*/
int32_t ucnv_copyPlatformString(char *platformString, UConverterPlatform platform);
#endif /* _UCNV_IMP */