Skip to content
Snippets Groups Projects
Commit 1e1f9e91 authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Another attempt was made

parent 886fb9f3
No related branches found
No related tags found
No related merge requests found
...@@ -116,6 +116,18 @@ unsigned int decode( char const * fiveChars ) throw( bad_input_data ) ...@@ -116,6 +116,18 @@ unsigned int decode( char const * fiveChars ) throw( bad_input_data )
} }
*/ */
char to_char(size_t i)
{
if (i <= 9)
{
return static_cast<char>('0' + i);
}
else
{
return static_cast<char>('a' + (i - 10));
}
}
// Common to all UUID implementations // Common to all UUID implementations
void LLUUID::to_chars(char* out) const void LLUUID::to_chars(char* out) const
{ {
...@@ -171,23 +183,27 @@ void LLUUID::to_chars(char* out) const ...@@ -171,23 +183,27 @@ void LLUUID::to_chars(char* out) const
memcpy(out, buffer, UUID_STR_SIZE-1); memcpy(out, buffer, UUID_STR_SIZE-1);
#else #else
alignas(16) char result[UUID_STR_SIZE - 1] = {}; // Temporary aligned output buffer for simd op
for (size_t i = 0, cur_pos = 0; i < UUID_BYTES; ++i) for (size_t i = 0, cur_pos = 0; i < UUID_BYTES; ++i)
{ {
const U8 uuid_byte = mData[i]; const U8 uuid_byte = mData[i];
const size_t hi = ((uuid_byte) >> 4) & 0x0F; const size_t hi = ((uuid_byte) >> 4) & 0x0F;
out[cur_pos] = (i <= 9) ? static_cast<char>('0' + hi) : static_cast<char>('a' + (hi-10)); result[cur_pos] = to_char(hi);
++cur_pos; cur_pos++;
const size_t lo = (uuid_byte) & 0x0F; const size_t lo = (uuid_byte) & 0x0F;
out[cur_pos] = (i <= 9) ? static_cast<char>('0' + lo) : static_cast<char>('a' + (lo-10)); result[cur_pos] = to_char(lo);
++cur_pos; cur_pos++;
if (i == 3 || i == 5 || i == 7 || i == 9) if (i == 3 || i == 5 || i == 7 || i == 9)
{ {
out[cur_pos] = '-'; result[cur_pos] = '-';
++cur_pos; cur_pos++;
} }
} }
memcpy(out, result, UUID_STR_SIZE - 1);
#endif #endif
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment