Skip to content

Commit

Permalink
Cleanup following review
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday committed Sep 11, 2024
1 parent 0957572 commit 6c13b25
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 121 deletions.
3 changes: 1 addition & 2 deletions plugins/timelib/timelib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,6 @@ TIMELIB_API unsigned int TIMELIB_CALL tlAdjustCalendar(unsigned int date, short
unsigned int month = (date - (year * 10000)) / 100;
unsigned int day = date - (year * 10000) - (month * 100);
int expectedMonthVal = month - 1;
time_t seconds [[maybe_unused]];
unsigned int result = 0;

// Normalize the expected month value
Expand All @@ -823,7 +822,7 @@ TIMELIB_API unsigned int TIMELIB_CALL tlAdjustCalendar(unsigned int date, short
timeInfo.tm_mon += month_delta;
timeInfo.tm_isdst = -1;

seconds = tlMKTime(&timeInfo);
tlMKTime(&timeInfo);

if (timeInfo.tm_mon != expectedMonthVal)
{
Expand Down
1 change: 1 addition & 0 deletions roxie/roxiemem/roxiemem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8425,6 +8425,7 @@ class RoxieMemTests : public CppUnit::TestFixture

for (unsigned pass=0; pass < 8; pass++)
{
//numPagesAfterCleanup() also has the side-effect of freeing up any empty pages.
[[maybe_unused]] unsigned numPagesFull = rowManager->numPagesAfterCleanup(true);
unsigned numRowsLeft = 0;
unsigned target=0;
Expand Down
100 changes: 0 additions & 100 deletions system/jhtree/jhinplace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,83 +267,6 @@ inline void skipPacked(const byte * & cur)
} while (next >= 0x80);
}

//----- special packed format - code is untested

#ifdef ALTERNATIVE_PACKING_FORMAT
inline unsigned getLeadingMask(byte extraBytes) { return (0x100U - (1U << (8-extraBytes))); }
inline unsigned getLeadingValueMask(byte extraBytes) { return (~getLeadingMask(extraBytes)) >> 1; }

static void serializePacked2(MemoryBuffer & out, size32_t value)
{
//Efficiency of serialization is not the key consideration
byte mask = 0;
unsigned size = sizePacked(value);
constexpr unsigned maxBytes = 9;
byte result[maxBytes];

for (unsigned i=1; i < size; i++)
{
result[maxBytes - i] = value;
value >>= 8;
mask = 0x80 | (mask >> 1);
}
unsigned start = maxBytes - size;
result[start] |= mask;
out.append(size, result + start);
}

inline unsigned numExtraBytesFromFirst1(byte first)
{
if (first >= 0xF0)
if (first >= 0xFC)
if (first >= 0xFE)
if (first >= 0xFF)
return 8;
else
return 7;
else
return 6;
else
if (first >= 0xF8)
return 5;
else
return 4;
else
if (first >= 0xC0)
if (first >= 0xE0)
return 3;
else
return 2;
else
return (first >> 7); // (first >= 0x80) ? 1 : 0
}

inline unsigned numExtraBytesFromFirst2(byte first)
{
//Surely should be faster, but seems slower on AMD. Retest in its actual context
unsigned value = first;
return countLeadingUnsetBits(~(value << 24));
}

inline unsigned numExtraBytesFromFirst(byte first)
{
return numExtraBytesFromFirst1(first);
}

inline unsigned readPacked2(const byte * & cur)
{
byte first = *cur++;
unsigned extraBytes = numExtraBytesFromFirst(first);
unsigned value = first & getLeadingValueMask(extraBytes);
while (extraBytes--)
{
value <<= 8;
value |= *cur++;
}
return value;
}
#endif

//-------------------

static unsigned bytesRequired(unsigned __int64 value)
Expand Down Expand Up @@ -2694,32 +2617,9 @@ static int normalizeCompare(int x)
class InplaceIndexTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( InplaceIndexTest );
//CPPUNIT_TEST(testBytesFromFirstTiming);
CPPUNIT_TEST(testSearching);
CPPUNIT_TEST_SUITE_END();

#ifdef ALTERNATIVE_PACKING_FORMAT
void testBytesFromFirstTiming()
{
for (unsigned i=0; i <= 0xff; i++)
assertex(numExtraBytesFromFirst1(i) == numExtraBytesFromFirst2(i));
unsigned total = 0;
{
CCycleTimer timer;
for (unsigned i=0; i < 0xffffff; i++)
total += numExtraBytesFromFirst1(i);
printf("%llu\n", timer.elapsedNs());
}
{
CCycleTimer timer;
for (unsigned i2=0; i2 < 0xffffff; i2++)
total += numExtraBytesFromFirst2(i2);
printf("%llu\n", timer.elapsedNs());
}
printf("%u\n", total);
}
#endif

void testSearching()
{
const size32_t keyLen = 8;
Expand Down
20 changes: 3 additions & 17 deletions system/jhtree/keybuild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,16 +271,9 @@ class CKeyBuilder : public CInterfaceOf<IKeyBuilder>
}

protected:
offset_t endLevel(bool close)
void nextLevel()
{
return 0;
}

offset_t nextLevel()
{
endLevel(false);
levels++;
return 0;
}

void writeFileHeader(bool fixHdr, CRC32 *crc)
Expand Down Expand Up @@ -415,15 +408,8 @@ class CKeyBuilder : public CInterfaceOf<IKeyBuilder>
if (children.ordinality() != 1)
{
// Note that we used to always create at least 2 levels as various places used to assume this.
offset_t offset = nextLevel();
if (offset)
{
ForEachItemIn(idx, children)
{
CNodeInfo &info = children.item(idx);
info.pos += offset;
}
}
nextLevel();

NodeInfoArray parentInfo;
buildLevel(children, parentInfo);
buildTree(parentInfo);
Expand Down
3 changes: 1 addition & 2 deletions system/lzma/LzmaEnc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1923,11 +1923,10 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize
static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
{
UInt32 beforeSize = kNumOpts;
Bool btMode [[maybe_unused]];
if (!RangeEnc_Alloc(&p->rc, alloc))
return SZ_ERROR_MEM;
btMode = (p->matchFinderBase.btMode != 0);
#ifdef COMPRESS_MF_MT
Bool btMode = (p->matchFinderBase.btMode != 0);
p->mtMode = (p->multiThread && !p->fastMode && btMode);
#endif

Expand Down

0 comments on commit 6c13b25

Please sign in to comment.