Commit Graph

223 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto 8ff001ef30 Avoid crashing of Array#unshift; fix #4808
On cases like `a.unshift(*a)`.
2019-11-08 10:57:18 +09:00
KOBAYASHI Shuji 0bedd900b9 Remove mrb_get_args(mrb, ""); ref 30f37872 2019-09-18 16:07:21 +09:00
Yukihiro "Matz" Matsumoto 57d7fe94a9 Add a macro mrb_frozen_p that points to MRB_FROZEN_P. 2019-09-14 23:21:44 +09:00
dearblue 279c21b816 Prohibit changes to iseq in principle 2019-08-18 15:00:32 +09:00
Yukihiro "Matz" Matsumoto 5b1f25a4e0 Implement Array#each using inline mruby bytecode. 2019-08-17 14:46:32 +09:00
KOBAYASHI Shuji 334afb167c Use new specifiers/modifiers of mrb_vfromat()
The binary sizes (gems are only `mruby-bin-mruby`) are reduced slightly in
my environment than before the introduction of new specifiers/modifiers
(5116789a) with this change.

  ------------+-------------------+-------------------+--------
   BINARY     | BEFORE (5116789a) |   AFTER (This PR) |  RATIO
  ------------+-------------------+-------------------+--------
   mruby      |      593416 bytes |      593208 bytes | -0.04%
   libmruby.a |      769048 bytes |      767264 bytes | -0.23%
  ------------+-------------------+-------------------+--------

BTW, I accidentally changed `tasks/toolchains/visualcpp.rake` at #4613,
so I put it back.
2019-08-05 13:18:50 +09:00
KOBAYASHI Shuji 1fd08aee15 Fix argument specs to Array 2019-06-23 20:01:33 +09:00
dearblue 56e0e1934d Name the return value of mrb_range_beg_len() 2019-05-25 12:12:21 +09:00
KOBAYASHI Shuji e3beef065c Extract frozen checking to function 2019-04-09 18:23:11 +09:00
KOBAYASHI Shuji 5adef8ba44 Move Array#(append|prepend) from core to mruby-ary-ext
They are not included in ISO standard.
2019-04-06 17:40:51 +09:00
Takashi Sawanaka d8c70167f7 Make mrb_ary_clear() function callable from C again 2018-12-15 05:17:38 +09:00
Yukihiro "Matz" Matsumoto 698f5f707c Removed to_ary conversion method. 2018-11-19 12:08:28 +09:00
Yukihiro "Matz" Matsumoto 7ff84789c3 Add argument check to Array#clear; fix #4144 2018-10-29 10:12:10 +09:00
Yukihiro "Matz" Matsumoto e9b1d9dc2f Array size may be changed in mrb_get_args() reentry.
fix #4116; fix #4117; fix #4118; fix #4119; fix #4120
2018-09-18 07:07:43 +09:00
dearblue 366848996a Clear terminated space 2018-09-07 22:32:34 +09:00
Takeshi Watanabe e66c990234 Fix array replace leak error in mruby-uri. 2018-04-25 13:27:00 +09:00
Yukihiro "Matz" Matsumoto 54905e98cf ary_dup() should not use `ary_replace(); fix #4004
Otherwise the duplicated object may have shared entities that
should not be modified in-line.
2018-04-18 17:30:33 +09:00
Yukihiro "Matz" Matsumoto 391e24210f A new function ary_from_values(); ref #4004 2018-04-18 17:29:45 +09:00
Yukihiro "Matz" Matsumoto 0e76faed8c Make ary_replace() to share entry buffers if possible. 2018-04-17 17:21:45 +09:00
Yukihiro "Matz" Matsumoto 5c15aa2f3b Make ary_concat() to replace the receiver when it is empty. 2018-04-17 12:34:30 +09:00
Yukihiro "Matz" Matsumoto c078783a5a Make ary_replace() to take struct RArray* argument. 2018-04-17 12:33:01 +09:00
Yukihiro "Matz" Matsumoto d88191e7e7 Implement Array#__svalue in C. 2018-04-17 11:32:31 +09:00
Takeshi Watanabe 1218ff5d47 Set array length after expanding capacity. 2018-03-19 21:40:17 +09:00
Yukihiro "Matz" Matsumoto bbb0882343 Modifying frozen objects will raise FrozenError.
`FrozenError` is a subclass of `RuntimeError` which used to be
raised.  [Ruby2.5]
2017-12-12 18:41:18 +09:00
Yukihiro "Matz" Matsumoto 03a3bd9178 The number of argument should be retrieved by mrb_get_argc; fix #3848
You should not access `mrb->c->ci->argc` directly.
2017-11-13 16:16:38 +09:00
YAMAMOTO Masaya acdc2d1f24 Add MRB_WITHOUT_FLOAT 2017-10-11 17:58:11 +09:00
Yukihiro "Matz" Matsumoto 85a400e43d Reimplement Array#shift to be faster. 2017-08-26 02:03:21 +09:00
Yukihiro "Matz" Matsumoto cec53ff77e Array#first to treat 1 argument case specially to improve performance. 2017-08-26 02:03:21 +09:00
Yukihiro "Matz" Matsumoto 9146d5c34f Zero width unshift should not touch memory; ref #3780 2017-08-19 11:11:26 +09:00
Yukihiro "Matz" Matsumoto 8b3298b2d6 Unshift pointer move size was wrong (not len but alen); fix #3780 2017-08-19 11:08:46 +09:00
Yukihiro "Matz" Matsumoto 8fbc4bef55 Reduce signed/unsigned comparison warnings; ref #3785 2017-08-18 22:54:59 +09:00
Yukihiro "Matz" Matsumoto f1767fd079 Separate mrb_str_buf_new and mrb_str_new_capa.
`mrb_str_buf_new` is an old function that ensures capacity size of
`MRB_STR_BUF_MIN_SIZE` minimum. Usually one need to use
`mrb_str_new_capa` instead.
2017-08-18 22:17:48 +09:00
Miura Hideki 75ec86ed00 Improve Array structure 2017-08-18 20:12:00 +09:00
Yukihiro "Matz" Matsumoto ef0b239704 Remove unnecessary inline function ary_elt.
And the function does not conform the naming convention anyway.
2017-08-11 12:57:37 +09:00
Yukihiro "Matz" Matsumoto 006661394d Fixed heap buffer overflow in mrb_ary_unshift_m; fix #3760 2017-08-05 01:18:52 +09:00
Yukihiro "Matz" Matsumoto f26d00d9e8 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.
2017-07-27 16:13:06 +09:00
Yukihiro "Matz" Matsumoto a18904a4c2 Use "$!" specifier of mrb_get_args. 2017-07-12 14:49:55 +09:00
Yukihiro "Matz" Matsumoto 059d707e3a Add ary_modify_check() to Array#unshift; ref #3737 2017-07-12 14:44:36 +09:00
ksss bf48473cf6 Should only check frozen for Array#pop 2017-07-09 18:05:21 +09:00
ksss e581f2ed97 Should only check frozen fix #3737 2017-07-09 17:47:10 +09:00
Yukihiro "Matz" Matsumoto bf1cb87b34 Array size can be cause integer overflow; fix #3710 2017-06-20 20:19:37 +09:00
Yukihiro "Matz" Matsumoto aa8121cf3a Use mrb_int instead of size_t for array capacity and length. 2017-06-17 08:39:43 +09:00
Yukihiro "Matz" Matsumoto 2837de95fe Prevent splicing big recursive arrrays; ref #3679
We know this is not perfect, but this change makes hack like #3679
bit harder. Harmless for useful cases.
2017-05-31 23:03:39 +09:00
Yukihiro "Matz" Matsumoto 3e07a2d77c Silence warnings caused by implicit type casting. 2017-04-25 21:00:16 +09:00
Yukihiro "Matz" Matsumoto 5a445f012e Add alias "append" to Array#push, and "prepend" to Array#unshift.
According to CRuby [Feature#12746]
2017-04-01 21:27:23 +09:00
okkez 6dbe2272cf Set proper class to subclass of Array
More compatibility to CRuby.
2017-03-29 08:02:21 +09:00
Yukihiro "Matz" Matsumoto 09574922a9 Should not check/call to_str for immediate objects; ref #3515 2017-03-19 20:59:30 +09:00
Yukihiro "Matz" Matsumoto 6db38c3768 Need not to call mrb_obj_as_string() is sep is nil. 2017-03-19 00:28:52 +09:00
Yukihiro "Matz" Matsumoto 72bff2932b Use size_t to avoid integer overflow in mrb_ary_splice(); fix #3413 2017-01-24 11:36:27 +09:00
ksss 78a395d446 Refactoring: Use array_copy instead of for loop 2017-01-23 15:18:48 +09:00