diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-07-27 12:46:51 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-07-27 16:13:06 +0900 |
| commit | f26d00d9e81b102fababdd9c0d1b886fab30e35a (patch) | |
| tree | 057788919d060adb7d0045ef6a67cd0a7ae63d8f /src/class.c | |
| parent | 5d44f8582eb2f3011145861692d9ad42975f7a74 (diff) | |
| download | mruby-f26d00d9e81b102fababdd9c0d1b886fab30e35a.tar.gz mruby-f26d00d9e81b102fababdd9c0d1b886fab30e35a.zip | |
Embed small size array elements in the heap.
It reduces the memory consumption and sometimes improve the
performance as well. For example, the consumed memory size
of `bench/bm_ao_render.rb` is reduced from 1.2GB to 1GB, and
its total execution time become 18.795 sec from 22.229 sec.
Diffstat (limited to 'src/class.c')
| -rw-r--r-- | src/class.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/class.c b/src/class.c index 41a0fbad8..56f64fd4e 100644 --- a/src/class.c +++ b/src/class.c @@ -564,7 +564,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...) va_list ap; int argc = mrb->c->ci->argc; int arg_i = 0; - mrb_bool array_argv; + mrb_value *array_argv; mrb_bool opt = FALSE; mrb_bool given = TRUE; @@ -572,15 +572,15 @@ mrb_get_args(mrb_state *mrb, const char *format, ...) if (argc < 0) { struct RArray *a = mrb_ary_ptr(mrb->c->stack[1]); - argc = a->len; - array_argv = TRUE; + argc = ARY_LEN(a); + array_argv = ARY_PTR(a); } else { - array_argv = FALSE; + array_argv = NULL; } #define ARGV \ - (array_argv ? mrb_ary_ptr(mrb->c->stack[1])->ptr : (mrb->c->stack + 1)) + (array_argv ? array_argv : (mrb->c->stack + 1)) while ((c = *format++)) { switch (c) { @@ -751,8 +751,8 @@ mrb_get_args(mrb_state *mrb, const char *format, ...) if (i < argc) { aa = to_ary(mrb, ARGV[arg_i++]); a = mrb_ary_ptr(aa); - *pb = a->ptr; - *pl = a->len; + *pb = ARY_PTR(a); + *pl = ARY_LEN(a); i++; } } @@ -896,7 +896,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...) { mrb_value **var; mrb_int *pl; - mrb_bool nocopy = FALSE; + mrb_bool nocopy = array_argv ? TRUE : FALSE; if (*format == '!') { format++; @@ -913,7 +913,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...) else { mrb_value args = mrb_ary_new_from_values(mrb, *pl, ARGV+arg_i); RARRAY(args)->c = NULL; - *var = (mrb_value*)RARRAY_PTR(args); + *var = RARRAY_PTR(args); } } i = argc; |
