mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-16 10:17:23 +00:00
ICU-1030
Code review and optimizations updates for String Search. X-SVN-Rev: 5717
This commit is contained in:
parent
412f48860e
commit
2e6080b73e
5 changed files with 731 additions and 694 deletions
|
@ -1335,7 +1335,7 @@ inline uint32_t ucol_IGetPrevCE(const UCollator *coll, collIterate *data,
|
|||
data->toReturn --;
|
||||
result = *(data->toReturn);
|
||||
if (data->CEs == data->toReturn) {
|
||||
data->CEpos = data->toReturn = data->CEs;
|
||||
data->CEpos = data->toReturn;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -371,6 +371,7 @@ ucol_cloneRuleData(const UCollator *coll, int32_t *length, UErrorCode *status);
|
|||
/* StringSearch internal use */
|
||||
#define inNormBuf(coleiter) ((coleiter)->iteratordata_.flags & UCOL_ITER_INNORMBUF)
|
||||
#define isFCDPointerNull(coleiter) ((coleiter)->iteratordata_.fcdPosition == NULL)
|
||||
#define hasExpansion(coleiter) ((coleiter)->iteratordata_.CEpos != (coleiter)->iteratordata_.CEs)
|
||||
#define getExpansionPrefix(coleiter) ((coleiter)->iteratordata_.toReturn - (coleiter)->iteratordata_.CEs)
|
||||
#define setExpansionPrefix(coleiter, offset) ((coleiter)->iteratordata_.CEs + offset)
|
||||
#define getExpansionSuffix(coleiter) ((coleiter)->iteratordata_.CEpos - (coleiter)->iteratordata_.toReturn)
|
||||
|
|
|
@ -184,7 +184,8 @@ ucol_setText( UCollationElements *elems,
|
|||
}
|
||||
|
||||
elems->isWritable = FALSE;
|
||||
init_collIterate(elems->iteratordata_.coll, text, textLength, &elems->iteratordata_);
|
||||
init_collIterate(elems->iteratordata_.coll, text, textLength,
|
||||
&elems->iteratordata_);
|
||||
|
||||
elems->reset_ = TRUE;
|
||||
}
|
||||
|
@ -218,26 +219,17 @@ ucol_setOffset(UCollationElements *elems,
|
|||
return;
|
||||
}
|
||||
|
||||
/* this methods will clean up any use of the writable buffer and points to the
|
||||
original string */
|
||||
// this methods will clean up any use of the writable buffer and points to
|
||||
// the original string
|
||||
collIterate *ci = &(elems->iteratordata_);
|
||||
ci->pos = ci->string + offset;
|
||||
ci->CEpos = ci->toReturn = ci->CEs;
|
||||
if (ci->flags & UCOL_ITER_INNORMBUF) {
|
||||
ci->flags = ci->origFlags;
|
||||
ci->flags = ci->origFlags;
|
||||
}
|
||||
if ((ci->flags & UCOL_ITER_HASLEN) == 0) {
|
||||
ci->endp = ci->string + u_strlen(ci->string);
|
||||
}
|
||||
ci->flags = UCOL_ITER_HASLEN;
|
||||
if (ci->coll->normalizationMode == UCOL_ON) {
|
||||
ci->flags |= UCOL_ITER_NORM;
|
||||
}
|
||||
if (ci->stackWritableBuffer != ci->writableBuffer)
|
||||
{
|
||||
uprv_free(ci->writableBuffer);
|
||||
/* reseting UCOL_ITER_INNORMBUF */
|
||||
ci->writableBuffer = ci->stackWritableBuffer;
|
||||
ci->endp = ci->string + u_strlen(ci->string);
|
||||
ci->flags |= UCOL_ITER_HASLEN;
|
||||
}
|
||||
ci->fcdPosition = NULL;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -15,7 +15,7 @@
|
|||
#include "unicode/ubrk.h"
|
||||
|
||||
#define INITIAL_ARRAY_SIZE_ 256
|
||||
#define MAX_TABLE_SIZE_ 256
|
||||
#define MAX_TABLE_SIZE_ 257
|
||||
|
||||
struct USearch {
|
||||
// required since collation element iterator does not have a getText API
|
||||
|
@ -35,17 +35,17 @@ struct USearch {
|
|||
};
|
||||
|
||||
struct UPattern {
|
||||
const UChar *text;
|
||||
int32_t textLength; // exact length
|
||||
const UChar *text;
|
||||
int32_t textLength; // exact length
|
||||
// length required for backwards ce comparison
|
||||
int32_t CELength;
|
||||
uint32_t *CE;
|
||||
uint32_t CEBuffer[INITIAL_ARRAY_SIZE_];
|
||||
UBool hasPrefixAccents;
|
||||
UBool hasSuffixAccents;
|
||||
int32_t defaultShiftSize;
|
||||
int32_t shift[MAX_TABLE_SIZE_];
|
||||
int32_t backShift[MAX_TABLE_SIZE_];
|
||||
int32_t CELength;
|
||||
uint32_t *CE;
|
||||
uint32_t CEBuffer[INITIAL_ARRAY_SIZE_];
|
||||
UBool hasPrefixAccents;
|
||||
UBool hasSuffixAccents;
|
||||
int16_t defaultShiftSize;
|
||||
int16_t shift[MAX_TABLE_SIZE_];
|
||||
int16_t backShift[MAX_TABLE_SIZE_];
|
||||
};
|
||||
|
||||
struct UStringSearch {
|
||||
|
@ -55,6 +55,9 @@ struct UStringSearch {
|
|||
// positions within the collation element iterator is used to determine
|
||||
// if we are at the start of the text.
|
||||
UCollationElements *textIter;
|
||||
// utility collation element, used throughout program for temporary
|
||||
// iteration.
|
||||
UCollationElements *utilIter;
|
||||
UBool ownCollator;
|
||||
UBool toNormalize;
|
||||
UCollationStrength strength;
|
||||
|
|
Loading…
Add table
Reference in a new issue