Unverified Commit c769013f authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #4277 from shuujii/extract-code-fragment-for-unpacking-in-sym_inline_unpack

Extract code fragment for unpacking into method in `sym_inline_unpack()`
parents cc94c8bf 5b10439f
......@@ -69,31 +69,15 @@ sym_inline_pack(const char *name, uint16_t len)
}
static const char*
sym_inline_unpack(mrb_sym sym, char *buf)
sym_inline_unpack_with_bit(mrb_sym sym, char *buf, int bit_per_char)
{
int i;
mrb_assert(sym&1);
if (sym&2) { /* all lower case (5bits/char) */
for (i=0; i<6; i++) {
uint32_t bits;
char c;
bits = sym>>(i*5+2) & 31;
if (bits == 0) break;
c = pack_table[bits-1];
buf[i] = c;
}
buf[i] = '\0';
return buf;
}
for (i=0; i<5; i++) {
for (i=0; i<30/bit_per_char; i++) {
uint32_t bits;
char c;
bits = sym>>(i*6+2) & 63;
bits = sym>>(i*bit_per_char+2) & (1<<bit_per_char)-1;
if (bits == 0) break;
c = pack_table[bits-1];
buf[i] = c;
......@@ -101,6 +85,17 @@ sym_inline_unpack(mrb_sym sym, char *buf)
buf[i] = '\0';
return buf;
}
static const char*
sym_inline_unpack(mrb_sym sym, char *buf)
{
mrb_assert(sym&1);
if (sym&2) { /* all lower case (5bits/char) */
return sym_inline_unpack_with_bit(sym, buf, 5);
}
return sym_inline_unpack_with_bit(sym, buf, 6);
}
#endif
uint8_t
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment