1
0
Fork 0

DBG: more efficient ToCompressedHex function (emits bytes directly if repeated 1 or 2 times)

This commit is contained in:
mrexodia 2016-06-24 07:10:46 +02:00
parent 24a94edd78
commit 43319be9d6
No known key found for this signature in database
GPG Key ID: D72F9A4FAA0073B4
1 changed files with 7 additions and 1 deletions

View File

@ -359,7 +359,13 @@ String StringUtils::ToCompressedHex(unsigned char* buffer, size_t size)
result.push_back(HEXLOOKUP[lastCh & 0xF]);
for(; i < size && buffer[i] == lastCh; i++)
repeat++;
result.append(StringUtils::sprintf("{%" fext "X}", repeat));
if(repeat == 2)
{
result.push_back(HEXLOOKUP[(lastCh >> 4) & 0xF]);
result.push_back(HEXLOOKUP[lastCh & 0xF]);
}
else if(repeat > 2)
result.append(StringUtils::sprintf("{%" fext "X}", repeat));
}
return result;
}