diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-06-07 16:51:40 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-06-07 16:51:40 +0900 |
| commit | 20dc629b11cb5cb650bd6826e0e789cf887d1e74 (patch) | |
| tree | 1e4d212a9f9820a0651f50f581d976cbaed8e7ab /src/string.c | |
| parent | 24b02955d362fcb7962ccf874158550c1f67aaa2 (diff) | |
| download | mruby-20dc629b11cb5cb650bd6826e0e789cf887d1e74.tar.gz mruby-20dc629b11cb5cb650bd6826e0e789cf887d1e74.zip | |
inline str_discard(); ref #2370
Diffstat (limited to 'src/string.c')
| -rw-r--r-- | src/string.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/string.c b/src/string.c index 6fa9271e1..fc5d43612 100644 --- a/src/string.c +++ b/src/string.c @@ -2523,17 +2523,6 @@ mrb_str_bytes(mrb_state *mrb, mrb_value str) return a; } -static inline void -str_discard(mrb_state *mrb, mrb_value str) { - struct RString *s = mrb_str_ptr(str); - - if (!STR_SHARED_P(s) && !STR_EMBED_P(s) && ((s->flags & MRB_STR_NOFREE) == 0)) { - mrb_free(mrb, s->as.heap.ptr); - RSTRING(str)->as.heap.ptr = 0; - RSTRING(str)->as.heap.len = 0; - } -} - /* * call-seq: * string.clear -> string @@ -2548,7 +2537,11 @@ mrb_str_clear(mrb_state *mrb, mrb_value str) { struct RString *s = mrb_str_ptr(str); - str_discard(mrb, str); + if (!STR_SHARED_P(s) && !STR_EMBED_P(s) && ((s->flags & MRB_STR_NOFREE) == 0)) { + mrb_free(mrb, s->as.heap.ptr); + RSTRING(str)->as.heap.ptr = 0; + RSTRING(str)->as.heap.len = 0; + } STR_SET_EMBED_FLAG(s); STR_SET_EMBED_LEN(s, 0); RSTRING_PTR(str)[0] = '\0'; |
