mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 07:39:16 +00:00
ICU-6112 Reset a converter about 20% faster. This is helpful when converting many small strings. In the overall scheme of things, it's not that significant since a reset is generally quick.
X-SVN-Rev: 23137
This commit is contained in:
parent
10611e82fd
commit
da6bcd2c16
2 changed files with 29 additions and 24 deletions
|
@ -565,34 +565,35 @@ static void _reset(UConverter *converter, UConverterResetChoice choice,
|
|||
|
||||
if(callCallback) {
|
||||
/* first, notify the callback functions that the converter is reset */
|
||||
UConverterToUnicodeArgs toUArgs = {
|
||||
sizeof(UConverterToUnicodeArgs),
|
||||
TRUE,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
UConverterFromUnicodeArgs fromUArgs = {
|
||||
sizeof(UConverterFromUnicodeArgs),
|
||||
TRUE,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
UErrorCode errorCode;
|
||||
|
||||
toUArgs.converter = fromUArgs.converter = converter;
|
||||
if(choice<=UCNV_RESET_TO_UNICODE) {
|
||||
if(choice<=UCNV_RESET_TO_UNICODE && converter->fromCharErrorBehaviour != UCNV_TO_U_DEFAULT_CALLBACK) {
|
||||
UConverterToUnicodeArgs toUArgs = {
|
||||
sizeof(UConverterToUnicodeArgs),
|
||||
TRUE,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
toUArgs.converter = converter;
|
||||
errorCode = U_ZERO_ERROR;
|
||||
converter->fromCharErrorBehaviour(converter->toUContext, &toUArgs, NULL, 0, UCNV_RESET, &errorCode);
|
||||
}
|
||||
if(choice!=UCNV_RESET_TO_UNICODE) {
|
||||
if(choice!=UCNV_RESET_TO_UNICODE && converter->fromUCharErrorBehaviour != UCNV_FROM_U_DEFAULT_CALLBACK) {
|
||||
UConverterFromUnicodeArgs fromUArgs = {
|
||||
sizeof(UConverterFromUnicodeArgs),
|
||||
TRUE,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
fromUArgs.converter = converter;
|
||||
errorCode = U_ZERO_ERROR;
|
||||
converter->fromUCharErrorBehaviour(converter->fromUContext, &fromUArgs, NULL, 0, 0, UCNV_RESET, &errorCode);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 1999-2006, International Business Machines
|
||||
* Copyright (C) 1999-2007, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
*
|
||||
|
@ -87,6 +87,10 @@ ucnv_unloadSharedDataIfReady(UConverterSharedData *sharedData);
|
|||
void
|
||||
ucnv_incrementRefCount(UConverterSharedData *sharedData);
|
||||
|
||||
/**
|
||||
* These are the default error handling callbacks for the charset conversion framework.
|
||||
* For performance reasons, they are only called to handle an error (not normally called for a reset or close).
|
||||
*/
|
||||
#define UCNV_TO_U_DEFAULT_CALLBACK ((UConverterToUCallback) UCNV_TO_U_CALLBACK_SUBSTITUTE)
|
||||
#define UCNV_FROM_U_DEFAULT_CALLBACK ((UConverterFromUCallback) UCNV_FROM_U_CALLBACK_SUBSTITUTE)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue