diff options
author | mcheshkov <mcheshkov@yandex-team.ru> | 2022-02-10 16:46:16 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:16 +0300 |
commit | 1312621288956f199a5bd5342b0133d4395fa725 (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /contrib/libs/icu/common/utrie2_builder.cpp | |
parent | e9d19cec64684c9c1e6b0c98297e5b895cf904fe (diff) | |
download | ydb-1312621288956f199a5bd5342b0133d4395fa725.tar.gz |
Restoring authorship annotation for <mcheshkov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/icu/common/utrie2_builder.cpp')
-rw-r--r-- | contrib/libs/icu/common/utrie2_builder.cpp | 154 |
1 files changed, 77 insertions, 77 deletions
diff --git a/contrib/libs/icu/common/utrie2_builder.cpp b/contrib/libs/icu/common/utrie2_builder.cpp index fbcd80041f..8de824cc3d 100644 --- a/contrib/libs/icu/common/utrie2_builder.cpp +++ b/contrib/libs/icu/common/utrie2_builder.cpp @@ -1,4 +1,4 @@ -// © 2016 and later: Unicode, Inc. and others. +// © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html /* ****************************************************************************** @@ -8,7 +8,7 @@ * ****************************************************************************** * file name: utrie2_builder.cpp -* encoding: UTF-8 +* encoding: UTF-8 * tab size: 8 (not used) * indentation:4 * @@ -24,23 +24,23 @@ * This file contains only the builder code. * See utrie2.c for the runtime and enumeration code. */ -// #define UTRIE2_DEBUG +// #define UTRIE2_DEBUG #ifdef UTRIE2_DEBUG # include <stdio.h> #endif -// #define UCPTRIE_DEBUG +// #define UCPTRIE_DEBUG #include "unicode/utypes.h" -#ifdef UCPTRIE_DEBUG -#include "unicode/ucptrie.h" -#include "unicode/umutablecptrie.h" -#include "ucptrie_impl.h" -#endif +#ifdef UCPTRIE_DEBUG +#include "unicode/ucptrie.h" +#include "unicode/umutablecptrie.h" +#include "ucptrie_impl.h" +#endif #include "cmemory.h" #include "utrie2.h" #include "utrie2_impl.h" -#include "utrie.h" // for utrie2_fromUTrie() +#include "utrie.h" // for utrie2_fromUTrie() /* Implementation notes ----------------------------------------------------- */ @@ -139,14 +139,14 @@ utrie2_open(uint32_t initialValue, uint32_t errorValue, UErrorCode *pErrorCode) trie->errorValue=errorValue; trie->highStart=0x110000; trie->newTrie=newTrie; -#ifdef UTRIE2_DEBUG - trie->name="open"; -#endif +#ifdef UTRIE2_DEBUG + trie->name="open"; +#endif newTrie->data=data; -#ifdef UCPTRIE_DEBUG - newTrie->t3=umutablecptrie_open(initialValue, errorValue, pErrorCode); -#endif +#ifdef UCPTRIE_DEBUG + newTrie->t3=umutablecptrie_open(initialValue, errorValue, pErrorCode); +#endif newTrie->dataCapacity=UNEWTRIE2_INITIAL_DATA_LENGTH; newTrie->initialValue=initialValue; newTrie->errorValue=errorValue; @@ -259,14 +259,14 @@ cloneBuilder(const UNewTrie2 *other) { uprv_free(trie); return NULL; } -#ifdef UCPTRIE_DEBUG - if(other->t3==nullptr) { - trie->t3=nullptr; - } else { - UErrorCode errorCode=U_ZERO_ERROR; - trie->t3=umutablecptrie_clone(other->t3, &errorCode); - } -#endif +#ifdef UCPTRIE_DEBUG + if(other->t3==nullptr) { + trie->t3=nullptr; + } else { + UErrorCode errorCode=U_ZERO_ERROR; + trie->t3=umutablecptrie_clone(other->t3, &errorCode); + } +#endif trie->dataCapacity=other->dataCapacity; /* clone data */ @@ -309,7 +309,7 @@ utrie2_clone(const UTrie2 *other, UErrorCode *pErrorCode) { trie=(UTrie2 *)uprv_malloc(sizeof(UTrie2)); if(trie==NULL) { - *pErrorCode=U_MEMORY_ALLOCATION_ERROR; + *pErrorCode=U_MEMORY_ALLOCATION_ERROR; return NULL; } uprv_memcpy(trie, other, sizeof(UTrie2)); @@ -334,7 +334,7 @@ utrie2_clone(const UTrie2 *other, UErrorCode *pErrorCode) { } if(trie->memory==NULL && trie->newTrie==NULL) { - *pErrorCode=U_MEMORY_ALLOCATION_ERROR; + *pErrorCode=U_MEMORY_ALLOCATION_ERROR; uprv_free(trie); trie=NULL; } @@ -366,22 +366,22 @@ copyEnumRange(const void *context, UChar32 start, UChar32 end, uint32_t value) { } #ifdef UTRIE2_DEBUG -static long countInitial(const UTrie2 *trie) { - uint32_t initialValue=trie->initialValue; - int32_t length=trie->dataLength; - long count=0; - if(trie->data16!=nullptr) { - for(int32_t i=0; i<length; ++i) { - if(trie->data16[i]==initialValue) { ++count; } - } - } else { - for(int32_t i=0; i<length; ++i) { - if(trie->data32[i]==initialValue) { ++count; } - } - } - return count; -} - +static long countInitial(const UTrie2 *trie) { + uint32_t initialValue=trie->initialValue; + int32_t length=trie->dataLength; + long count=0; + if(trie->data16!=nullptr) { + for(int32_t i=0; i<length; ++i) { + if(trie->data16[i]==initialValue) { ++count; } + } + } else { + for(int32_t i=0; i<length; ++i) { + if(trie->data32[i]==initialValue) { ++count; } + } + } + return count; +} + static void utrie_printLengths(const UTrie *trie) { long indexLength=trie->indexLength; @@ -396,8 +396,8 @@ utrie2_printLengths(const UTrie2 *trie, const char *which) { long indexLength=trie->indexLength; long dataLength=(long)trie->dataLength; long totalLength=(long)sizeof(UTrie2Header)+indexLength*2+dataLength*(trie->data32!=NULL ? 4 : 2); - printf("**UTrie2Lengths(%s %s)** index:%6ld data:%6ld countInitial:%6ld serialized:%6ld\n", - which, trie->name, indexLength, dataLength, countInitial(trie), totalLength); + printf("**UTrie2Lengths(%s %s)** index:%6ld data:%6ld countInitial:%6ld serialized:%6ld\n", + which, trie->name, indexLength, dataLength, countInitial(trie), totalLength); } #endif @@ -661,9 +661,9 @@ set32(UNewTrie2 *trie, *pErrorCode=U_NO_WRITE_PERMISSION; return; } -#ifdef UCPTRIE_DEBUG - umutablecptrie_set(trie->t3, c, value, pErrorCode); -#endif +#ifdef UCPTRIE_DEBUG + umutablecptrie_set(trie->t3, c, value, pErrorCode); +#endif block=getDataBlock(trie, c, forLSCP); if(block<0) { @@ -759,9 +759,9 @@ utrie2_setRange32(UTrie2 *trie, *pErrorCode=U_NO_WRITE_PERMISSION; return; } -#ifdef UCPTRIE_DEBUG - umutablecptrie_setRange(newTrie->t3, start, end, value, pErrorCode); -#endif +#ifdef UCPTRIE_DEBUG + umutablecptrie_setRange(newTrie->t3, start, end, value, pErrorCode); +#endif if(!overwrite && value==newTrie->initialValue) { return; /* nothing to do */ } @@ -777,7 +777,7 @@ utrie2_setRange32(UTrie2 *trie, return; } - nextStart=(start+UTRIE2_DATA_MASK)&~UTRIE2_DATA_MASK; + nextStart=(start+UTRIE2_DATA_MASK)&~UTRIE2_DATA_MASK; if(nextStart<=limit) { fillBlock(newTrie->data+block, start&UTRIE2_DATA_MASK, UTRIE2_DATA_BLOCK_LENGTH, value, newTrie->initialValue, overwrite); @@ -1028,10 +1028,10 @@ findHighStart(UNewTrie2 *trie, uint32_t highValue) { */ static void compactData(UNewTrie2 *trie) { -#ifdef UTRIE2_DEBUG - int32_t countSame=0, sumOverlaps=0; -#endif - +#ifdef UTRIE2_DEBUG + int32_t countSame=0, sumOverlaps=0; +#endif + int32_t start, newStart, movedStart; int32_t blockLength, overlap; int32_t i, mapIndex, blockCount; @@ -1072,9 +1072,9 @@ compactData(UNewTrie2 *trie) { if( (movedStart=findSameDataBlock(trie->data, newStart, start, blockLength)) >=0 ) { -#ifdef UTRIE2_DEBUG - ++countSame; -#endif +#ifdef UTRIE2_DEBUG + ++countSame; +#endif /* found an identical block, set the other block's index value for the current block */ for(i=blockCount, mapIndex=start>>UTRIE2_SHIFT_2; i>0; --i) { trie->map[mapIndex++]=movedStart; @@ -1094,9 +1094,9 @@ compactData(UNewTrie2 *trie) { overlap>0 && !equal_uint32(trie->data+(newStart-overlap), trie->data+start, overlap); overlap-=UTRIE2_DATA_GRANULARITY) {} -#ifdef UTRIE2_DEBUG - sumOverlaps+=overlap; -#endif +#ifdef UTRIE2_DEBUG + sumOverlaps+=overlap; +#endif if(overlap>0 || newStart<start) { /* some overlap, or just move the whole block */ movedStart=newStart-overlap; @@ -1136,8 +1136,8 @@ compactData(UNewTrie2 *trie) { #ifdef UTRIE2_DEBUG /* we saved some space */ - printf("compacting UTrie2: count of 32-bit data words %lu->%lu countSame=%ld sumOverlaps=%ld\n", - (long)trie->dataLength, (long)newStart, (long)countSame, (long)sumOverlaps); + printf("compacting UTrie2: count of 32-bit data words %lu->%lu countSame=%ld sumOverlaps=%ld\n", + (long)trie->dataLength, (long)newStart, (long)countSame, (long)sumOverlaps); #endif trie->dataLength=newStart; @@ -1218,7 +1218,7 @@ compactIndex2(UNewTrie2 *trie) { #ifdef UTRIE2_DEBUG /* we saved some space */ - printf("compacting UTrie2: count of 16-bit index words %lu->%lu\n", + printf("compacting UTrie2: count of 16-bit index words %lu->%lu\n", (long)trie->index2Length, (long)newStart); #endif @@ -1248,7 +1248,7 @@ compactTrie(UTrie2 *trie, UErrorCode *pErrorCode) { trie->highStart=newTrie->highStart=highStart; #ifdef UTRIE2_DEBUG - printf("UTrie2: highStart U+%06lx highValue 0x%lx initialValue 0x%lx\n", + printf("UTrie2: highStart U+%06lx highValue 0x%lx initialValue 0x%lx\n", (long)highStart, (long)highValue, (long)trie->initialValue); #endif @@ -1266,7 +1266,7 @@ compactTrie(UTrie2 *trie, UErrorCode *pErrorCode) { compactIndex2(newTrie); #ifdef UTRIE2_DEBUG } else { - printf("UTrie2: highStart U+%04lx count of 16-bit index words %lu->%lu\n", + printf("UTrie2: highStart U+%04lx count of 16-bit index words %lu->%lu\n", (long)highStart, (long)trie->newTrie->index2Length, (long)UTRIE2_INDEX_1_OFFSET); #endif } @@ -1389,7 +1389,7 @@ utrie2_freeze(UTrie2 *trie, UTrie2ValueBits valueBits, UErrorCode *pErrorCode) { if(highStart<=0x10000) { trie->index2NullOffset=0xffff; } else { - trie->index2NullOffset=static_cast<uint16_t>(UTRIE2_INDEX_2_OFFSET+newTrie->index2NullOffset); + trie->index2NullOffset=static_cast<uint16_t>(UTRIE2_INDEX_2_OFFSET+newTrie->index2NullOffset); } trie->dataNullOffset=(uint16_t)(dataMove+newTrie->dataNullOffset); trie->highValueIndex=dataMove+trie->dataLength-UTRIE2_DATA_GRANULARITY; @@ -1466,16 +1466,16 @@ utrie2_freeze(UTrie2 *trie, UTrie2ValueBits valueBits, UErrorCode *pErrorCode) { return; } -#ifdef UTRIE2_DEBUG - utrie2_printLengths(trie, ""); -#endif - -#ifdef UCPTRIE_DEBUG - umutablecptrie_setName(newTrie->t3, trie->name); - ucptrie_close( - umutablecptrie_buildImmutable( - newTrie->t3, UCPTRIE_TYPE_FAST, (UCPTrieValueWidth)valueBits, pErrorCode)); -#endif +#ifdef UTRIE2_DEBUG + utrie2_printLengths(trie, ""); +#endif + +#ifdef UCPTRIE_DEBUG + umutablecptrie_setName(newTrie->t3, trie->name); + ucptrie_close( + umutablecptrie_buildImmutable( + newTrie->t3, UCPTRIE_TYPE_FAST, (UCPTrieValueWidth)valueBits, pErrorCode)); +#endif /* Delete the UNewTrie2. */ uprv_free(newTrie->data); uprv_free(newTrie); |