mrubyを超漢字で動作させる
修訂 | 1300770cec6b6a20c33dc54c9c01fc07c5097088 (tree) |
---|---|
時間 | 2014-07-06 19:30:29 |
作者 | Yukihiro "Matz" Matsumoto <matz@ruby...> |
Commiter | Yukihiro "Matz" Matsumoto |
Merge pull request #2447 from take-cheeze/reduce_ary_clear_alloc
Reduce allocation in shared RArray clearing.
@@ -902,10 +902,14 @@ mrb_ary_clear(mrb_state *mrb, mrb_value self) | ||
902 | 902 | { |
903 | 903 | struct RArray *a = mrb_ary_ptr(self); |
904 | 904 | |
905 | - ary_modify(mrb, a); | |
905 | + if (ARY_SHARED_P(a)) { | |
906 | + mrb_ary_decref(mrb, a->aux.shared); | |
907 | + ARY_UNSET_SHARED_FLAG(a); | |
908 | + } else { | |
909 | + mrb_free(mrb, a->ptr); | |
910 | + } | |
906 | 911 | a->len = 0; |
907 | 912 | a->aux.capa = 0; |
908 | - mrb_free(mrb, a->ptr); | |
909 | 913 | a->ptr = 0; |
910 | 914 | |
911 | 915 | return self; |