ICU-8915 document why bmpset.cpp:set32x64Bits(..., limit=0x800) is fine & safe

X-SVN-Rev: 31000
This commit is contained in:
Markus Scherer 2011-12-01 06:46:53 +00:00
parent b19d1bd16a
commit 540221ad33

View File

@ -67,8 +67,8 @@ static void set32x64Bits(uint32_t table[64], int32_t start, int32_t limit) {
U_ASSERT(start<limit);
U_ASSERT(limit<=0x800);
int32_t lead=start>>6;
int32_t trail=start&0x3f;
int32_t lead=start>>6; // Named for UTF-8 2-byte lead byte with upper 5 bits.
int32_t trail=start&0x3f; // Named for UTF-8 2-byte trail byte with lower 6 bits.
// Set one bit indicating an all-one block.
uint32_t bits=(uint32_t)1<<lead;
@ -104,6 +104,9 @@ static void set32x64Bits(uint32_t table[64], int32_t start, int32_t limit) {
table[trail]|=bits;
}
}
// limit<=0x800. If limit==0x800 then limitLead=32 and limitTrail=0.
// In that case, bits=1<<limitLead is undefined but the bits value
// is not used because trail<limitTrail is already false.
bits=1<<limitLead;
for(trail=0; trail<limitTrail; ++trail) {
table[trail]|=bits;