ICU-5426 Make it easier to change the size of the converter hash table depending on the platform.
X-SVN-Rev: 20464
This commit is contained in:
parent
a7a3fe85db
commit
932759f00a
@ -363,6 +363,15 @@ getAlgorithmicTypeFromName(const char *realName)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Based on the number of known converters, this determines how many times larger
|
||||||
|
* the shared data hash table should be. When on small platforms, or just a couple
|
||||||
|
* of converters are used, this number should be 2. When memory is plentiful, or
|
||||||
|
* when ucnv_countAvailable is ever used, this should be 4.
|
||||||
|
* Larger numbers reduce the number of hash collisions, but use more memory.
|
||||||
|
*/
|
||||||
|
#define UCNV_CACHE_LOAD_FACTOR 4
|
||||||
|
|
||||||
/* Puts the shared data in the static hashtable SHARED_DATA_HASHTABLE */
|
/* Puts the shared data in the static hashtable SHARED_DATA_HASHTABLE */
|
||||||
/* Will always be called with the cnvCacheMutex alrady being held */
|
/* Will always be called with the cnvCacheMutex alrady being held */
|
||||||
/* by the calling function. */
|
/* by the calling function. */
|
||||||
@ -379,7 +388,7 @@ ucnv_shareConverterData(UConverterSharedData * data)
|
|||||||
if (SHARED_DATA_HASHTABLE == NULL)
|
if (SHARED_DATA_HASHTABLE == NULL)
|
||||||
{
|
{
|
||||||
SHARED_DATA_HASHTABLE = uhash_openSize(uhash_hashChars, uhash_compareChars, NULL,
|
SHARED_DATA_HASHTABLE = uhash_openSize(uhash_hashChars, uhash_compareChars, NULL,
|
||||||
ucnv_io_countTotalAliases(&err),
|
ucnv_io_countKnownConverters(&err)*UCNV_CACHE_LOAD_FACTOR,
|
||||||
&err);
|
&err);
|
||||||
ucln_common_registerCleanup(UCLN_COMMON_UCNV, ucnv_cleanup);
|
ucln_common_registerCleanup(UCLN_COMMON_UCNV, ucnv_cleanup);
|
||||||
|
|
||||||
@ -1040,6 +1049,9 @@ static UBool haveAvailableConverterList(UErrorCode *pErrorCode) {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Open the default converter to make sure that it has first dibs in the hash table. */
|
||||||
|
ucnv_close(ucnv_createConverter(&tempConverter, NULL, &localStatus));
|
||||||
|
|
||||||
localConverterCount = 0;
|
localConverterCount = 0;
|
||||||
|
|
||||||
for (idx = 0; idx < allConverterCount; idx++) {
|
for (idx = 0; idx < allConverterCount; idx++) {
|
||||||
|
@ -1069,9 +1069,9 @@ ucnv_openAllNames(UErrorCode *pErrorCode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
U_CFUNC uint16_t
|
U_CFUNC uint16_t
|
||||||
ucnv_io_countTotalAliases(UErrorCode *pErrorCode) {
|
ucnv_io_countKnownConverters(UErrorCode *pErrorCode) {
|
||||||
if (haveAliasData(pErrorCode)) {
|
if (haveAliasData(pErrorCode)) {
|
||||||
return (uint16_t)gMainTable.aliasListSize;
|
return (uint16_t)gMainTable.converterListSize;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -95,13 +95,12 @@ U_CFUNC const char *
|
|||||||
ucnv_io_getConverterName(const char *alias, UBool *containsOption, UErrorCode *pErrorCode);
|
ucnv_io_getConverterName(const char *alias, UBool *containsOption, UErrorCode *pErrorCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the number of all aliases and converter names.
|
* Return the number of all known converter names (no aliases).
|
||||||
* This is helpful if you need a number for creating an alias table.
|
|
||||||
* @param pErrorCode The error code
|
* @param pErrorCode The error code
|
||||||
* @return the number of all aliases
|
* @return the number of all aliases
|
||||||
*/
|
*/
|
||||||
U_CFUNC uint16_t
|
U_CFUNC uint16_t
|
||||||
ucnv_io_countTotalAliases(UErrorCode *pErrorCode);
|
ucnv_io_countKnownConverters(UErrorCode *pErrorCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swap an ICU converter alias table. See implementation for details.
|
* Swap an ICU converter alias table. See implementation for details.
|
||||||
|
@ -85,7 +85,7 @@ u_init(UErrorCode *status) {
|
|||||||
* available.
|
* available.
|
||||||
*/
|
*/
|
||||||
#if !UCONFIG_NO_CONVERSION
|
#if !UCONFIG_NO_CONVERSION
|
||||||
ucnv_io_countTotalAliases(status);
|
ucnv_io_countKnownConverters(status);
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
/* Do any required init for services that don't have open operations
|
/* Do any required init for services that don't have open operations
|
||||||
|
Loading…
Reference in New Issue
Block a user