the performance of the CUInt128::toBinaryString() &
CUInt128::toHexString() functions.
first, i checked the code and netfinity's change to
CUInt128::toHexString() is wrong since the
the m_data array is treated differently in CUInt128
then it's treated in EncodeBase16() as unsigned char...
second, i wanted to use his code but since it's not
the right solution, i've wrote 2 functions to do the job:
Quote
CString kadEncodeBase2(const uint32* pBuffer, int nLen)
{
static const char base2Chars[3] = "01";
char str[129] = {0};
char* p = str;
for (int i = 0; i < nLen; i++)
{
for (int j = 31; j >= 0; j--)
{
*p++ = base2Chars[ (pBuffer[i] >> j) & 1 ];
}
}
*p = 0;
return CString(str);
}
CString kadEncodeBase16(const uint32* pBuffer, int nLen)
{
static const char base16Chars[17] = "0123456789ABCDEF";
char str[33] = {0};
char* p = str;
for (int i = 0; i < nLen; i++)
{
for (int j = 28; j >= 0; j -= 4)
{
*p++ = base16Chars[ (pBuffer[i] >> j) & 0xf ];
}
}
*p = 0;
return CString(str);
}
// end Avi3k: improve toString
function call (within the class):
Quote
as u can see, i didn't change Kad's code yet,
i want to know if this code is really better and also
if it's ok to modify Kad's code with these changes...
if so, i plan on merging the code to CUInt128 class
(will also save a function call

fyi, i checked the code more than once in a
separate (VC) project with the functions taken from
eMule to compare the functions' output, it worked 100%

btw, <OffTopic>
i saw some files are still in the source code and are not used:
ListBoxST.cpp/h, LayeredWindowHelperST.cpp/h, BtnST.cpp/h...
didn't want to open a new topic just for that

</OffTopic>
Regards,
Avi3k
This post has been edited by Avi-3k: 10 September 2005 - 07:09 PM