diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-01-23 15:24:56 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-01-23 15:24:56 +0900 |
| commit | 40ec03c8c221f5915923a3f3a1eb3055767fc6b3 (patch) | |
| tree | 40ec70077a5d8f16a8193b623df3917abd10531d /src | |
| parent | 4d38cad31b2107d23fa393561eb5dae5da16c82c (diff) | |
| parent | 78a395d44607b52a256cd41016210ece1a739538 (diff) | |
| download | mruby-40ec03c8c221f5915923a3f3a1eb3055767fc6b3.tar.gz mruby-40ec03c8c221f5915923a3f3a1eb3055767fc6b3.zip | |
Merge pull request #3412 from ksss/mrb_ary_splice
Refactoring: Use array_copy instead of for loop
Diffstat (limited to 'src')
| -rw-r--r-- | src/array.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/array.c b/src/array.c index e41183d68..9e5b90061 100644 --- a/src/array.c +++ b/src/array.c @@ -590,7 +590,7 @@ mrb_ary_splice(mrb_state *mrb, mrb_value ary, mrb_int head, mrb_int len, mrb_val { struct RArray *a = mrb_ary_ptr(ary); const mrb_value *argv; - mrb_int i, argc; + mrb_int argc; ary_modify(mrb, a); @@ -631,9 +631,7 @@ mrb_ary_splice(mrb_state *mrb, mrb_value ary, mrb_int head, mrb_int len, mrb_val } ary_fill_with_nil(a->ptr + a->len, head - a->len); if (argc > 0) { - for (i = 0; i < argc; i++) { - a->ptr[head + i] = argv[i]; - } + array_copy(a->ptr + head, argv, argc); } a->len = len; } |
