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
Yukihiro "Matz" Matsumoto
5e1d923381
Changed the behavior of mrb_range_beg_len(); close #3411
...
The new API is:
int mrb_range_beg_len(mrb, range, &beg, &len, len, trunc)
The new argument `trunc` is a boolean value that specifies
whether the function truncates the range. The new return value
is an integer instead of a boolean, that is:
0: not a range
1: range with proper edges
2: out of range
To get the old behavior, you have to rewrite:
mrb_range_beg_len(mrb, range, &beg, &len, len)
to:
mrn_range_beg_len(mrb, range, &beg, &len, len, TRUE) == 1
[Breaking Change]
2017-01-23 14:35:26 +09:00
Yukihiro "Matz" Matsumoto
49fd7590df
Use mrb_write_barrier() instead of mrb_field_write_barrier_value()
...
ref #3409
2017-01-23 10:32:33 +09:00
Yukihiro "Matz" Matsumoto
fdec607cd0
Remove unnecessary inline declaration; ref #3409
2017-01-23 10:30:14 +09:00
Yukihiro "Matz" Matsumoto
9d0f07e6a7
Merge pull request #3409 from ksss/mrb_ary_splice
...
Rewrite mrb_ary_splice
2017-01-23 10:28:09 +09:00
ksss
b49bd70f59
Should raise RuntimeError when object frozen
2017-01-22 18:53:20 +09:00
ksss
65c9baae7c
Rewrite mrb_ary_splice
...
Referenced to CRuby's array.c(rb_ary_splice)
fix #3405
2017-01-22 14:06:23 +09:00
Yukihiro "Matz" Matsumoto
392d7fbef9
Add ary_modify() checks; close #3379
...
This issue was reported by https://hackerone.com/an0n-j
2017-01-07 12:26:29 +09:00
Yukihiro "Matz" Matsumoto
885d929398
Improve capacity enhancing conditions
2017-01-06 14:53:00 +09:00
Yukihiro "Matz" Matsumoto
cfdd1e3cc6
ary_expand_capa(): refine conditions to avoid infinite loop; ref #3353
2016-12-31 23:22:17 +09:00
Yukihiro "Matz" Matsumoto
9d84f0d47b
ary_expand_capa(): size calculation by size_t; fix #3353
...
Also more size checks added.
2016-12-31 23:09:56 +09:00