Optimize for more common case

--HG--
branch : cdb-packed
hg/feature/cdb-packed
kaetemi 10 years ago
parent 9fec239dfb
commit 5d9f3ce668

@ -128,21 +128,11 @@ void CCDBNodeLeaf::write( CTextId& id, FILE * f)
inline uint readPackedBitCount(CBitMemStream & f)
{
uint64 isPacked;
f.serial(isPacked, 1);
if (isPacked)
{
uint64 bitCount;
f.serial(bitCount, 4);
uint bits = (bitCount << 2) + 4;
nlinfo("PACKED: %u bits", (uint32)(bits));
return bits;
}
else
{
nlinfo("PACKED: Not packed");
return 64;
}
uint64 nibbleCount;
f.serial(nibbleCount, 4);
uint bits = (nibbleCount << 2);
nlinfo("PACKED: %u bits", (uint32)(bits));
return bits;
}
//-----------------------------------------------

@ -526,59 +526,45 @@ inline void pushPackedValue( CBitMemStream& s, uint64 value, uint32& bitsize, ui
if (next) // 64bit
{
bits += 32;
test = next;
test = next; // 32 msb
}
else
{
test = (uint32)(value & 0xFFFFFFFF);
test = (uint32)(value & 0xFFFFFFFF); // 32 lsb
}
next >>= 16;
next = (test >> 16);
if (next)
{
bits += 16;
test = next;
test = next; // 16 msb
}
else
{
test = next & 0xFFFF;
test = (test & 0xFFFF); // 16 lsb
}
next >>= 8;
next = (test >> 8);
if (next)
{
bits += 8;
test = next;
test = next; // 8 msb
}
else
{
test = next & 0xFF;
test = (test & 0xFF); // 8 lsb
}
next >>= 4;
next = (test >> 4);
if (next)
{
bits += 4;
// test = next;
}
else
{
// test = next & 0xF;
}
if (bits + 5 > 64) // 1 bit isPacked, 4 bits bitCount
{
uint64 isPacked = 0;
s.serialAndLog2( isPacked, 1 );
s.serialAndLog2( value, 64 );
bitsize += 65;
bits += 8;
}
else
else if (test & 0xF)
{
uint64 isPacked = 1;
uint64 bitCount = bits >> 2;
bits += 4;
s.serialAndLog2( isPacked, 1 );
s.serialAndLog2( bitCount, 4 );
s.serialAndLog2( value, bits );
bitsize += (bits + 5);
}
uint64 nibbleCount = (bits >> 2);
s.serialAndLog2( nibbleCount, 4 );
s.serialAndLog2( value, bits );
bitsize += (4 + bits);
}
/*

Loading…
Cancel
Save