diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-03-07 18:51:32 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-03-07 18:51:32 +0900 |
| commit | ac8d04fb6c2072c9af0b0587044360dde3b3b77d (patch) | |
| tree | ab80df9179be235331935999dc4393670746a5ea /mrbgems/mruby-sprintf/src | |
| parent | 035898c7215c417e2ba24e759c033710ac74c6cc (diff) | |
| parent | 4bc19d5fadaf85523774eac29520cca03a1516b1 (diff) | |
| download | mruby-ac8d04fb6c2072c9af0b0587044360dde3b3b77d.tar.gz mruby-ac8d04fb6c2072c9af0b0587044360dde3b3b77d.zip | |
Merge pull request #1820 from ksss/string-embed
Embed small string
Diffstat (limited to 'mrbgems/mruby-sprintf/src')
| -rw-r--r-- | mrbgems/mruby-sprintf/src/sprintf.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/mrbgems/mruby-sprintf/src/sprintf.c b/mrbgems/mruby-sprintf/src/sprintf.c index ff9627437..8b0bff5be 100644 --- a/mrbgems/mruby-sprintf/src/sprintf.c +++ b/mrbgems/mruby-sprintf/src/sprintf.c @@ -712,7 +712,13 @@ retry: if (*p == 'p') arg = mrb_inspect(mrb, arg); str = mrb_obj_as_string(mrb, arg); len = RSTRING_LEN(str); - RSTRING_LEN(result) = blen; + if (RSTRING(result)->flags & MRB_STR_EMBED) { + int tmp_n = len; + RSTRING(result)->flags &= ~MRB_STR_EMBED_LEN_MASK; + RSTRING(result)->flags |= tmp_n << MRB_STR_EMBED_LEN_SHIFT; + } else { + RSTRING(result)->as.heap.len = blen; + } if (flags&(FPREC|FWIDTH)) { slen = RSTRING_LEN(str); if (slen < 0) { |
