ICU-6521 add utrie_enum() test data, improve utrie_enum() performance for 16-bit tries

X-SVN-Rev: 24536
This commit is contained in:
Markus Scherer 2008-09-01 11:45:56 +00:00
parent 16cea7af89
commit 8d40f30202
2 changed files with 28 additions and 11 deletions

View file

@ -1,7 +1,7 @@
/*
******************************************************************************
*
* Copyright (C) 2001-2006, International Business Machines
* Copyright (C) 2001-2008, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
@ -1047,7 +1047,7 @@ utrie_enum(const UTrie *trie,
uint32_t value, prevValue, initialValue;
UChar32 c, prev;
int32_t l, i, j, block, prevBlock, offset;
int32_t l, i, j, block, prevBlock, nullBlock, offset;
/* check arguments */
if(trie==NULL || trie->index==NULL || enumRange==NULL) {
@ -1063,8 +1063,14 @@ utrie_enum(const UTrie *trie,
/* get the enumeration value that corresponds to an initial-value trie data entry */
initialValue=enumValue(context, trie->initialValue);
if(data32==NULL) {
nullBlock=trie->indexLength;
} else {
nullBlock=0;
}
/* set variables for previous range */
prevBlock=0;
prevBlock=nullBlock;
prev=0;
prevValue=initialValue;
@ -1082,7 +1088,7 @@ utrie_enum(const UTrie *trie,
if(block==prevBlock) {
/* the block is the same as the previous one, and filled with value */
c+=UTRIE_DATA_BLOCK_LENGTH;
} else if(block==0) {
} else if(block==nullBlock) {
/* this is the all-initial-value block */
if(prevValue!=initialValue) {
if(prev<c) {
@ -1090,7 +1096,7 @@ utrie_enum(const UTrie *trie,
return;
}
}
prevBlock=0;
prevBlock=nullBlock;
prev=c;
prevValue=initialValue;
}
@ -1106,6 +1112,7 @@ utrie_enum(const UTrie *trie,
}
}
if(j>0) {
/* the block is not filled with all the same value */
prevBlock=-1;
}
prev=c;
@ -1120,7 +1127,7 @@ utrie_enum(const UTrie *trie,
for(l=0xd800; l<0xdc00;) {
/* lead surrogate access */
offset=index[l>>UTRIE_SHIFT]<<UTRIE_INDEX_SHIFT;
if(offset==(data32!=NULL ? 0 : trie->indexLength)) {
if(offset==nullBlock) {
/* no entries for a whole block of lead surrogates */
if(prevValue!=initialValue) {
if(prev<c) {
@ -1128,7 +1135,7 @@ utrie_enum(const UTrie *trie,
return;
}
}
prevBlock=0;
prevBlock=nullBlock;
prev=c;
prevValue=initialValue;
}
@ -1150,7 +1157,7 @@ utrie_enum(const UTrie *trie,
return;
}
}
prevBlock=0;
prevBlock=nullBlock;
prev=c;
prevValue=initialValue;
}
@ -1167,7 +1174,7 @@ utrie_enum(const UTrie *trie,
if(block==prevBlock) {
/* the block is the same as the previous one, and filled with value */
c+=UTRIE_DATA_BLOCK_LENGTH;
} else if(block==0) {
} else if(block==nullBlock) {
/* this is the all-initial-value block */
if(prevValue!=initialValue) {
if(prev<c) {
@ -1175,7 +1182,7 @@ utrie_enum(const UTrie *trie,
return;
}
}
prevBlock=0;
prevBlock=nullBlock;
prev=c;
prevValue=initialValue;
}
@ -1191,6 +1198,7 @@ utrie_enum(const UTrie *trie,
}
}
if(j>0) {
/* the block is not filled with all the same value */
prevBlock=-1;
}
prev=c;

View file

@ -1,7 +1,7 @@
/*
******************************************************************************
*
* Copyright (C) 2001-2006, International Business Machines
* Copyright (C) 2001-2008, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
@ -745,6 +745,9 @@ setRanges2[]={
{0x2f800,0x2fedc, 0x7a, TRUE},
{0x72, 0xdd, 3, TRUE},
{0xdd, 0xde, 4, FALSE},
{0x201, 0x220, 6, TRUE}, /* 3 consecutive blocks with the same pattern but discontiguous value ranges */
{0x221, 0x240, 6, TRUE},
{0x241, 0x260, 6, TRUE},
{0x2f987,0x2fa98, 5, TRUE},
{0x2f777,0x2f833, 0, TRUE},
{0x2f900,0x2ffee, 1, FALSE},
@ -758,6 +761,12 @@ checkRanges2[]={
{0x72, 0x5555},
{0xdd, 3},
{0xde, 4},
{0x201, 0},
{0x220, 6},
{0x221, 0},
{0x240, 6},
{0x241, 0},
{0x260, 6},
{0x2f833,0},
{0x2f987,0x7a},
{0x2fa98,5},