Commit 65512f65 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2443 from suzukaze/use-mrb-str-emebed-macro

Use *_EMBED_* macro in state.c
parents 628615d9 569ea740
...@@ -190,9 +190,9 @@ mrb_str_pool(mrb_state *mrb, mrb_value str) ...@@ -190,9 +190,9 @@ mrb_str_pool(mrb_state *mrb, mrb_value str)
} }
else { else {
ns->flags = 0; ns->flags = 0;
if (s->flags & MRB_STR_EMBED) { if (RSTR_EMBED_P(s)) {
ptr = s->as.ary; ptr = s->as.ary;
len = (mrb_int)((s->flags & MRB_STR_EMBED_LEN_MASK) >> MRB_STR_EMBED_LEN_SHIFT); len = RSTR_EMBED_LEN(s);
} }
else { else {
ptr = s->as.heap.ptr; ptr = s->as.heap.ptr;
...@@ -200,9 +200,8 @@ mrb_str_pool(mrb_state *mrb, mrb_value str) ...@@ -200,9 +200,8 @@ mrb_str_pool(mrb_state *mrb, mrb_value str)
} }
if (len < RSTRING_EMBED_LEN_MAX) { if (len < RSTRING_EMBED_LEN_MAX) {
ns->flags |= MRB_STR_EMBED; RSTR_SET_EMBED_FLAG(ns);
ns->flags &= ~MRB_STR_EMBED_LEN_MASK; RSTR_SET_EMBED_LEN(ns, len);
ns->flags |= (size_t)len << MRB_STR_EMBED_LEN_SHIFT;
if (ptr) { if (ptr) {
memcpy(ns->as.ary, ptr, len); memcpy(ns->as.ary, ptr, len);
} }
......
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