2
0
mirror of https://github.com/boostorg/log.git synced 2026-02-11 11:52:20 +00:00

Fixes #10926. Generalized id formatting.

Also, different hex-based formatting routines now use the common
character table, which should reduce binary size a little.
This commit is contained in:
Andrey Semashev
2015-01-25 17:27:41 +03:00
parent 2afb87a3d9
commit 59f5bcdcad
7 changed files with 81 additions and 46 deletions

View File

@@ -52,8 +52,11 @@ extern dump_data_char32_t dump_data_char32_avx2;
enum { stride = 256 };
extern const char g_lowercase_dump_char_table[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
extern const char g_uppercase_dump_char_table[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
extern const char g_hex_char_table[2][16] =
{
{ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' },
{ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }
};
template< typename CharT >
void dump_data_generic(const void* data, std::size_t size, std::basic_ostream< CharT >& strm)
@@ -62,7 +65,7 @@ void dump_data_generic(const void* data, std::size_t size, std::basic_ostream< C
char_type buf[stride * 3u];
const char* const char_table = (strm.flags() & std::ios_base::uppercase) ? g_uppercase_dump_char_table : g_lowercase_dump_char_table;
const char* const char_table = g_hex_char_table[(strm.flags() & std::ios_base::uppercase) != 0];
const std::size_t stride_count = size / stride, tail_size = size % stride;
const uint8_t* p = static_cast< const uint8_t* >(data);