mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-29 11:02:08 +00:00
Revert "Fix endian issue in integer hex string conversion"
This commit is contained in:
parent
b784128c88
commit
a2e1269ef2
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <Core/Types.h>
|
|
||||||
|
|
||||||
/// Maps 0..15 to 0..9A..F or 0..9a..f correspondingly.
|
/// Maps 0..15 to 0..9A..F or 0..9a..f correspondingly.
|
||||||
|
|
||||||
@ -50,20 +50,6 @@ inline void writeBinByte(UInt8 byte, void * out)
|
|||||||
template <typename TUInt>
|
template <typename TUInt>
|
||||||
inline void writeHexUIntImpl(TUInt uint_, char * out, const char * const table)
|
inline void writeHexUIntImpl(TUInt uint_, char * out, const char * const table)
|
||||||
{
|
{
|
||||||
if constexpr (is_integer<TUInt>)
|
|
||||||
{
|
|
||||||
/// For integer types, use endian indepentant way for conversion
|
|
||||||
TUInt value = uint_;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < sizeof(TUInt); ++i)
|
|
||||||
{
|
|
||||||
memcpy(out + (sizeof(TUInt) - 1 - i) * 2, &table[static_cast<size_t>(value % 256) * 2], 2);
|
|
||||||
value /= 256;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/// For non-integer types, access memory directly for conversion to keep back-compatibility
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
TUInt value;
|
TUInt value;
|
||||||
@ -76,7 +62,6 @@ inline void writeHexUIntImpl(TUInt uint_, char * out, const char * const table)
|
|||||||
for (size_t i = 0; i < sizeof(TUInt); ++i)
|
for (size_t i = 0; i < sizeof(TUInt); ++i)
|
||||||
memcpy(out + i * 2, &table[static_cast<size_t>(uint8[sizeof(TUInt) - 1 - i]) * 2], 2);
|
memcpy(out + i * 2, &table[static_cast<size_t>(uint8[sizeof(TUInt) - 1 - i]) * 2], 2);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
template <typename TUInt>
|
template <typename TUInt>
|
||||||
inline void writeHexUIntUppercase(TUInt uint_, char * out)
|
inline void writeHexUIntUppercase(TUInt uint_, char * out)
|
||||||
|
Loading…
Reference in New Issue
Block a user