Commit 5b10439f authored by KOBAYASHI Shuji's avatar KOBAYASHI Shuji

Extract code fragment for unpacking into method in `sym_inline_unpack()`

parent cc94c8bf
...@@ -69,37 +69,32 @@ sym_inline_pack(const char *name, uint16_t len) ...@@ -69,37 +69,32 @@ sym_inline_pack(const char *name, uint16_t len)
} }
static const char* 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; int i;
mrb_assert(sym&1); for (i=0; i<30/bit_per_char; i++) {
if (sym&2) { /* all lower case (5bits/char) */
for (i=0; i<6; i++) {
uint32_t bits; uint32_t bits;
char c; char c;
bits = sym>>(i*5+2) & 31; bits = sym>>(i*bit_per_char+2) & (1<<bit_per_char)-1;
if (bits == 0) break; if (bits == 0) break;
c = pack_table[bits-1]; c = pack_table[bits-1];
buf[i] = c; buf[i] = c;
} }
buf[i] = '\0'; buf[i] = '\0';
return buf; return buf;
} }
for (i=0; i<5; i++) { static const char*
uint32_t bits; sym_inline_unpack(mrb_sym sym, char *buf)
char c; {
mrb_assert(sym&1);
bits = sym>>(i*6+2) & 63; if (sym&2) { /* all lower case (5bits/char) */
if (bits == 0) break; return sym_inline_unpack_with_bit(sym, buf, 5);
c = pack_table[bits-1];
buf[i] = c;
} }
buf[i] = '\0'; return sym_inline_unpack_with_bit(sym, buf, 6);
return buf;
} }
#endif #endif
......
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