Lines Matching refs:trie
113 allocIndex2Block(UNewTrie2 *trie);
117 UTrie2 *trie; in utrie2_open() local
126 trie=(UTrie2 *)uprv_malloc(sizeof(UTrie2)); in utrie2_open()
129 if(trie==NULL || newTrie==NULL || data==NULL) { in utrie2_open()
130 uprv_free(trie); in utrie2_open()
137 uprv_memset(trie, 0, sizeof(UTrie2)); in utrie2_open()
138 trie->initialValue=initialValue; in utrie2_open()
139 trie->errorValue=errorValue; in utrie2_open()
140 trie->highStart=0x110000; in utrie2_open()
141 trie->newTrie=newTrie; in utrie2_open()
143 trie->name="open"; in utrie2_open()
242 utrie2_set32(trie, i, initialValue, pErrorCode); in utrie2_open()
245 return trie; in utrie2_open()
250 UNewTrie2 *trie; in cloneBuilder() local
252 trie=(UNewTrie2 *)uprv_malloc(sizeof(UNewTrie2)); in cloneBuilder()
253 if(trie==NULL) { in cloneBuilder()
257 trie->data=(uint32_t *)uprv_malloc(other->dataCapacity*4); in cloneBuilder()
258 if(trie->data==NULL) { in cloneBuilder()
259 uprv_free(trie); in cloneBuilder()
264 trie->t3=nullptr; in cloneBuilder()
267 trie->t3=umutablecptrie_clone(other->t3, &errorCode); in cloneBuilder()
270 trie->dataCapacity=other->dataCapacity; in cloneBuilder()
273 uprv_memcpy(trie->index1, other->index1, sizeof(trie->index1)); in cloneBuilder()
274 uprv_memcpy(trie->index2, other->index2, (size_t)other->index2Length*4); in cloneBuilder()
275 trie->index2NullOffset=other->index2NullOffset; in cloneBuilder()
276 trie->index2Length=other->index2Length; in cloneBuilder()
278 uprv_memcpy(trie->data, other->data, (size_t)other->dataLength*4); in cloneBuilder()
279 trie->dataNullOffset=other->dataNullOffset; in cloneBuilder()
280 trie->dataLength=other->dataLength; in cloneBuilder()
284 trie->firstFreeBlock=0; in cloneBuilder()
286 uprv_memcpy(trie->map, other->map, ((size_t)other->dataLength>>UTRIE2_SHIFT_2)*4); in cloneBuilder()
287 trie->firstFreeBlock=other->firstFreeBlock; in cloneBuilder()
290 trie->initialValue=other->initialValue; in cloneBuilder()
291 trie->errorValue=other->errorValue; in cloneBuilder()
292 trie->highStart=other->highStart; in cloneBuilder()
293 trie->isCompacted=other->isCompacted; in cloneBuilder()
295 return trie; in cloneBuilder()
300 UTrie2 *trie; in utrie2_clone() local
310 trie=(UTrie2 *)uprv_malloc(sizeof(UTrie2)); in utrie2_clone()
311 if(trie==NULL) { in utrie2_clone()
314 uprv_memcpy(trie, other, sizeof(UTrie2)); in utrie2_clone()
317 trie->memory=uprv_malloc(other->length); in utrie2_clone()
318 if(trie->memory!=NULL) { in utrie2_clone()
319 trie->isMemoryOwned=TRUE; in utrie2_clone()
320 uprv_memcpy(trie->memory, other->memory, other->length); in utrie2_clone()
323 trie->index=(uint16_t *)trie->memory+(other->index-(uint16_t *)other->memory); in utrie2_clone()
325 trie->data16=(uint16_t *)trie->memory+(other->data16-(uint16_t *)other->memory); in utrie2_clone()
328 trie->data32=(uint32_t *)trie->memory+(other->data32-(uint32_t *)other->memory); in utrie2_clone()
332 trie->newTrie=cloneBuilder(other->newTrie); in utrie2_clone()
335 if(trie->memory==NULL && trie->newTrie==NULL) { in utrie2_clone()
336 uprv_free(trie); in utrie2_clone()
337 trie=NULL; in utrie2_clone()
339 return trie; in utrie2_clone()
343 UTrie2 *trie; member
351 if(value!=nt->trie->initialValue) { in copyEnumRange()
356 utrie2_set32(nt->trie, start, value, &nt->errorCode); in copyEnumRange()
358 utrie2_setRange32(nt->trie, start, end, value, TRUE, &nt->errorCode); in copyEnumRange()
367 static long countInitial(const UTrie2 *trie) { in countInitial() argument
368 uint32_t initialValue=trie->initialValue; in countInitial()
369 int32_t length=trie->dataLength; in countInitial()
371 if(trie->data16!=nullptr) { in countInitial()
373 if(trie->data16[i]==initialValue) { ++count; } in countInitial()
377 if(trie->data32[i]==initialValue) { ++count; } in countInitial()
384 utrie_printLengths(const UTrie *trie) { in utrie_printLengths() argument
385 long indexLength=trie->indexLength; in utrie_printLengths()
386 long dataLength=(long)trie->dataLength; in utrie_printLengths()
387 … long totalLength=(long)sizeof(UTrieHeader)+indexLength*2+dataLength*(trie->data32!=NULL ? 4 : 2); in utrie_printLengths()
393 utrie2_printLengths(const UTrie2 *trie, const char *which) { in utrie2_printLengths() argument
394 long indexLength=trie->indexLength; in utrie2_printLengths()
395 long dataLength=(long)trie->dataLength; in utrie2_printLengths()
396 … long totalLength=(long)sizeof(UTrie2Header)+indexLength*2+dataLength*(trie->data32!=NULL ? 4 : 2); in utrie2_printLengths()
398 which, trie->name, indexLength, dataLength, countInitial(trie), totalLength); in utrie2_printLengths()
419 context.trie=utrie2_open(other->initialValue, other->errorValue, pErrorCode); in utrie2_cloneAsThawed()
435 utrie2_set32ForLeadSurrogateCodeUnit(context.trie, lead, value, pErrorCode); in utrie2_cloneAsThawed()
439 utrie2_close(context.trie); in utrie2_cloneAsThawed()
440 context.trie=NULL; in utrie2_cloneAsThawed()
442 return context.trie; in utrie2_cloneAsThawed()
458 context.trie=utrie2_open(trie1->initialValue, errorValue, pErrorCode); in utrie2_fromUTrie()
474 utrie2_set32ForLeadSurrogateCodeUnit(context.trie, lead, value, pErrorCode); in utrie2_fromUTrie()
478 utrie2_freeze(context.trie, in utrie2_fromUTrie()
485 utrie2_printLengths(context.trie, "fromUTrie"); in utrie2_fromUTrie()
489 utrie2_close(context.trie); in utrie2_fromUTrie()
490 context.trie=NULL; in utrie2_fromUTrie()
492 return context.trie; in utrie2_fromUTrie()
496 isInNullBlock(UNewTrie2 *trie, UChar32 c, UBool forLSCP) { in isInNullBlock() argument
503 i2=trie->index1[c>>UTRIE2_SHIFT_1]+ in isInNullBlock()
506 block=trie->index2[i2]; in isInNullBlock()
507 return (UBool)(block==trie->dataNullOffset); in isInNullBlock()
511 allocIndex2Block(UNewTrie2 *trie) { in allocIndex2Block() argument
514 newBlock=trie->index2Length; in allocIndex2Block()
516 if(newTop>UPRV_LENGTHOF(trie->index2)) { in allocIndex2Block()
524 trie->index2Length=newTop; in allocIndex2Block()
525 …uprv_memcpy(trie->index2+newBlock, trie->index2+trie->index2NullOffset, UTRIE2_INDEX_2_BLOCK_LENGT… in allocIndex2Block()
530 getIndex2Block(UNewTrie2 *trie, UChar32 c, UBool forLSCP) { in getIndex2Block() argument
538 i2=trie->index1[i1]; in getIndex2Block()
539 if(i2==trie->index2NullOffset) { in getIndex2Block()
540 i2=allocIndex2Block(trie); in getIndex2Block()
544 trie->index1[i1]=i2; in getIndex2Block()
550 allocDataBlock(UNewTrie2 *trie, int32_t copyBlock) { in allocDataBlock() argument
553 if(trie->firstFreeBlock!=0) { in allocDataBlock()
555 newBlock=trie->firstFreeBlock; in allocDataBlock()
556 trie->firstFreeBlock=-trie->map[newBlock>>UTRIE2_SHIFT_2]; in allocDataBlock()
559 newBlock=trie->dataLength; in allocDataBlock()
561 if(newTop>trie->dataCapacity) { in allocDataBlock()
566 if(trie->dataCapacity<UNEWTRIE2_MEDIUM_DATA_LENGTH) { in allocDataBlock()
568 } else if(trie->dataCapacity<UNEWTRIE2_MAX_DATA_LENGTH) { in allocDataBlock()
582 uprv_memcpy(data, trie->data, (size_t)trie->dataLength*4); in allocDataBlock()
583 uprv_free(trie->data); in allocDataBlock()
584 trie->data=data; in allocDataBlock()
585 trie->dataCapacity=capacity; in allocDataBlock()
587 trie->dataLength=newTop; in allocDataBlock()
589 uprv_memcpy(trie->data+newBlock, trie->data+copyBlock, UTRIE2_DATA_BLOCK_LENGTH*4); in allocDataBlock()
590 trie->map[newBlock>>UTRIE2_SHIFT_2]=0; in allocDataBlock()
596 releaseDataBlock(UNewTrie2 *trie, int32_t block) { in releaseDataBlock() argument
598 trie->map[block>>UTRIE2_SHIFT_2]=-trie->firstFreeBlock; in releaseDataBlock()
599 trie->firstFreeBlock=block; in releaseDataBlock()
603 isWritableBlock(UNewTrie2 *trie, int32_t block) { in isWritableBlock() argument
604 return (UBool)(block!=trie->dataNullOffset && 1==trie->map[block>>UTRIE2_SHIFT_2]); in isWritableBlock()
608 setIndex2Entry(UNewTrie2 *trie, int32_t i2, int32_t block) { in setIndex2Entry() argument
610 ++trie->map[block>>UTRIE2_SHIFT_2]; /* increment first, in case block==oldBlock! */ in setIndex2Entry()
611 oldBlock=trie->index2[i2]; in setIndex2Entry()
612 if(0 == --trie->map[oldBlock>>UTRIE2_SHIFT_2]) { in setIndex2Entry()
613 releaseDataBlock(trie, oldBlock); in setIndex2Entry()
615 trie->index2[i2]=block; in setIndex2Entry()
625 getDataBlock(UNewTrie2 *trie, UChar32 c, UBool forLSCP) { in getDataBlock() argument
628 i2=getIndex2Block(trie, c, forLSCP); in getDataBlock()
634 oldBlock=trie->index2[i2]; in getDataBlock()
635 if(isWritableBlock(trie, oldBlock)) { in getDataBlock()
640 newBlock=allocDataBlock(trie, oldBlock); in getDataBlock()
645 setIndex2Entry(trie, i2, newBlock); in getDataBlock()
653 set32(UNewTrie2 *trie, in set32() argument
658 if(trie==NULL || trie->isCompacted) { in set32()
663 umutablecptrie_set(trie->t3, c, value, pErrorCode); in set32()
666 block=getDataBlock(trie, c, forLSCP); in set32()
672 trie->data[block+(c&UTRIE2_DATA_MASK)]=value; in set32()
676 utrie2_set32(UTrie2 *trie, UChar32 c, uint32_t value, UErrorCode *pErrorCode) { in utrie2_set32() argument
684 set32(trie->newTrie, c, TRUE, value, pErrorCode); in utrie2_set32()
688 utrie2_set32ForLeadSurrogateCodeUnit(UTrie2 *trie, in utrie2_set32ForLeadSurrogateCodeUnit() argument
698 set32(trie->newTrie, c, FALSE, value, pErrorCode); in utrie2_set32ForLeadSurrogateCodeUnit()
735 utrie2_setRange32(UTrie2 *trie, in utrie2_setRange32() argument
755 newTrie=trie->newTrie; in utrie2_setRange32()
942 findHighStart(UNewTrie2 *trie, uint32_t highValue) { in findHighStart() argument
949 data32=trie->data; in findHighStart()
950 initialValue=trie->initialValue; in findHighStart()
952 index2NullOffset=trie->index2NullOffset; in findHighStart()
953 nullBlock=trie->dataNullOffset; in findHighStart()
969 i2Block=trie->index1[--i1]; in findHighStart()
985 block=trie->index2[i2Block+ --i2]; in findHighStart()
1028 compactData(UNewTrie2 *trie) { in compactData() argument
1040 trie->map[i]=start; in compactData()
1049 for(start=newStart; start<trie->dataLength;) { in compactData()
1061 if(trie->map[start>>UTRIE2_SHIFT_2]<=0) { in compactData()
1070 if( (movedStart=findSameDataBlock(trie->data, newStart, start, blockLength)) in compactData()
1078 trie->map[mapIndex++]=movedStart; in compactData()
1092 overlap>0 && !equal_uint32(trie->data+(newStart-overlap), trie->data+start, overlap); in compactData()
1102 trie->map[mapIndex++]=movedStart; in compactData()
1109 trie->data[newStart++]=trie->data[start++]; in compactData()
1113 trie->map[mapIndex++]=start; in compactData()
1121 for(i=0; i<trie->index2Length; ++i) { in compactData()
1126 trie->index2[i]=trie->map[trie->index2[i]>>UTRIE2_SHIFT_2]; in compactData()
1128 trie->dataNullOffset=trie->map[trie->dataNullOffset>>UTRIE2_SHIFT_2]; in compactData()
1132 trie->data[newStart++]=trie->initialValue; in compactData()
1138 (long)trie->dataLength, (long)newStart, (long)countSame, (long)sumOverlaps); in compactData()
1141 trie->dataLength=newStart; in compactData()
1145 compactIndex2(UNewTrie2 *trie) { in compactIndex2() argument
1151 trie->map[i]=start; in compactIndex2()
1155 newStart+=UTRIE2_UTF8_2B_INDEX_2_LENGTH+((trie->highStart-0x10000)>>UTRIE2_SHIFT_1); in compactIndex2()
1157 for(start=UNEWTRIE2_INDEX_2_NULL_OFFSET; start<trie->index2Length;) { in compactIndex2()
1165 if( (movedStart=findSameIndex2Block(trie->index2, newStart, start)) in compactIndex2()
1169 trie->map[start>>UTRIE2_SHIFT_1_2]=movedStart; in compactIndex2()
1181 overlap>0 && !equal_int32(trie->index2+(newStart-overlap), trie->index2+start, overlap); in compactIndex2()
1186 trie->map[start>>UTRIE2_SHIFT_1_2]=newStart-overlap; in compactIndex2()
1191 trie->index2[newStart++]=trie->index2[start++]; in compactIndex2()
1194 trie->map[start>>UTRIE2_SHIFT_1_2]=start; in compactIndex2()
1202 trie->index1[i]=trie->map[trie->index1[i]>>UTRIE2_SHIFT_1_2]; in compactIndex2()
1204 trie->index2NullOffset=trie->map[trie->index2NullOffset>>UTRIE2_SHIFT_1_2]; in compactIndex2()
1214 trie->index2[newStart++]=(int32_t)0xffff<<UTRIE2_INDEX_SHIFT; in compactIndex2()
1220 (long)trie->index2Length, (long)newStart); in compactIndex2()
1223 trie->index2Length=newStart; in compactIndex2()
1227 compactTrie(UTrie2 *trie, UErrorCode *pErrorCode) { in compactTrie() argument
1232 newTrie=trie->newTrie; in compactTrie()
1235 highValue=utrie2_get32(trie, 0x10ffff); in compactTrie()
1239 highValue=trie->errorValue; in compactTrie()
1246 trie->highStart=newTrie->highStart=highStart; in compactTrie()
1250 (long)highStart, (long)highValue, (long)trie->initialValue); in compactTrie()
1256 utrie2_setRange32(trie, suppHighStart, 0x10ffff, trie->initialValue, TRUE, pErrorCode); in compactTrie()
1268 (long)highStart, (long)trie->newTrie->index2Length, (long)UTRIE2_INDEX_1_OFFSET); in compactTrie()
1279 newTrie->data[newTrie->dataLength++]=trie->initialValue; in compactTrie()
1304 utrie2_freeze(UTrie2 *trie, UTrie2ValueBits valueBits, UErrorCode *pErrorCode) { in utrie2_freeze() argument
1318 if( trie==NULL || in utrie2_freeze()
1324 newTrie=trie->newTrie; in utrie2_freeze()
1328 trie->data16!=NULL ? UTRIE2_16_VALUE_BITS : UTRIE2_32_VALUE_BITS; in utrie2_freeze()
1337 compactTrie(trie, pErrorCode); in utrie2_freeze()
1342 highStart=trie->highStart; in utrie2_freeze()
1377 trie->memory=uprv_malloc(length); in utrie2_freeze()
1378 if(trie->memory==NULL) { in utrie2_freeze()
1382 trie->length=length; in utrie2_freeze()
1383 trie->isMemoryOwned=TRUE; in utrie2_freeze()
1385 trie->indexLength=allIndexesLength; in utrie2_freeze()
1386 trie->dataLength=newTrie->dataLength; in utrie2_freeze()
1388 trie->index2NullOffset=0xffff; in utrie2_freeze()
1390 … trie->index2NullOffset=static_cast<uint16_t>(UTRIE2_INDEX_2_OFFSET+newTrie->index2NullOffset); in utrie2_freeze()
1392 trie->dataNullOffset=(uint16_t)(dataMove+newTrie->dataNullOffset); in utrie2_freeze()
1393 trie->highValueIndex=dataMove+trie->dataLength-UTRIE2_DATA_GRANULARITY; in utrie2_freeze()
1396 header=(UTrie2Header *)trie->memory; in utrie2_freeze()
1401 header->indexLength=(uint16_t)trie->indexLength; in utrie2_freeze()
1402 header->shiftedDataLength=(uint16_t)(trie->dataLength>>UTRIE2_INDEX_SHIFT); in utrie2_freeze()
1403 header->index2NullOffset=trie->index2NullOffset; in utrie2_freeze()
1404 header->dataNullOffset=trie->dataNullOffset; in utrie2_freeze()
1409 trie->index=dest16; in utrie2_freeze()
1449 trie->data16=dest16; in utrie2_freeze()
1450 trie->data32=NULL; in utrie2_freeze()
1458 trie->data16=NULL; in utrie2_freeze()
1459 trie->data32=(uint32_t *)dest16; in utrie2_freeze()
1468 utrie2_printLengths(trie, ""); in utrie2_freeze()
1472 umutablecptrie_setName(newTrie->t3, trie->name); in utrie2_freeze()
1480 trie->newTrie=NULL; in utrie2_freeze()