Commit Graph

41 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto 5b1f25a4e0 Implement Array#each using inline mruby bytecode. 2019-08-17 14:46:32 +09:00
Yukihiro "Matz" Matsumoto d605b72c1d Merge branch 'master' into i110/inspect-recursion 2019-07-17 10:35:41 +09:00
Yukihiro "Matz" Matsumoto af51119d3a Raise error on failed comparison in sort; ref #4307 2019-03-02 15:46:50 +09:00
Yukihiro "Matz" Matsumoto afca99a40b Remove implicit conversion using to_int method.
The ISO standard does not include implicit type conversion using
`to_int`. This implicit conversion often causes vulnerability.
There will be no more attacks like #4120.

In addition, we have added internal convenience method `__to_int` which
does type check and conversion (from floats).
2018-11-19 11:28:51 +09:00
Yukihiro "Matz" Matsumoto 34872e90d4 Re-implement Array#_inspect and Hash#_inspect without blocks.
To reduce the env object allocation; ref #4143
2018-10-29 11:55:49 +09:00
Tomoyuki Sahara 91444c4747 replace quicksort with mergesort. 2018-10-18 13:07:47 +09:00
Yukihiro "Matz" Matsumoto fee9ec61bb Make Array.new to accept both integers and floats.
This time we used `Integral` module which is mruby specific.
2018-08-13 23:15:52 +09:00
Ichito Nagata 2af92d0ebc Let inspect recursion do the right thing 2018-06-04 11:25:10 +09:00
Tomoyuki Sahara f0e54df4fe sort method should not consume system stack. 2018-04-23 12:28:15 +09:00
Yukihiro "Matz" Matsumoto d88191e7e7 Implement Array#__svalue in C. 2018-04-17 11:32:31 +09:00
Yukihiro "Matz" Matsumoto 1a8483f17e __sort_sub__ is a method defined in Array; fix #3970
Reorganize `__sort_sub__` arguments.
2018-03-16 14:49:51 +09:00
Christopher Aue c956e17c02 Replaced Array#each with while loop for performance reasons
Example benchmark:
$ time build/bench/bin/mruby -e "Array.new(2_000_000){ |i| i }.index{ |i| i == 1_999_999 }"

Before:
real    0m0.934s
user    0m0.922s
sys     0m0.003s

After:
real    0m0.590s
user    0m0.583s
sys     0m0.007s
2017-08-26 15:57:25 +02:00
Christopher Aue 3359b86ec7 Improved speed of enumeration methods 2017-07-30 13:19:31 +02:00
Yukihiro "Matz" Matsumoto 7b8d784040 Reimplement sort method to reduce array copying. 2017-07-25 14:42:38 +09:00
Jun Hiroe 88076901fd Refactor Array#each 2015-12-26 10:12:01 +09:00
Yusuke Tanaka d3f59db597 Remove redundant conditions of Array#each in ruby extension 2015-12-15 19:54:29 +09:00
go.kikuta 931a7223e6 array.rb: refactor (use onliner code if possible) 2015-08-21 14:56:49 +09:00
go.kikuta c326f065e1 array.rb: refactor some code 2015-08-19 16:17:06 +09:00
Franck Verrot 2588507285 Remove unnecessary backticks.
Dr Markus Kuhn published in 1999 an article [1] explaining in details
why we shouldn't use the ASCII grave accent (0x60) as a left quotation.

Backticks have been used most notably to produce nice-looking LaTeX
documents but it doesn't seem to be an issue on modern platforms and
for the oldest ones, there are workarounds as mentioned by Dr Kuhn.

[1]: https://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html
2015-06-24 13:07:07 +02:00
Yukihiro "Matz" Matsumoto b05d736b49 update mrblib/*.rb files to conform (some of) Rubocop checks 2015-05-29 17:01:52 +09:00
Yukihiro "Matz" Matsumoto 79fb18445d rescue SystemStackError that comes from inspecting self-referencing Hashes and Arrays; fix #2461 2014-07-12 23:22:20 +09:00
mirichi d2e4937cea Refactoring Array#__svalue 2014-04-25 21:36:52 +09:00
Yukihiro "Matz" Matsumoto b4043256d0 implement part of Array#<=> in C 2014-04-02 18:04:09 +09:00
Yukihiro "Matz" Matsumoto 94effc6a37 implement Array comparisons by Ruby 2014-04-02 17:33:25 +09:00
Yukihiro "Matz" Matsumoto d9feed6703 move Array#inspect implementation to mrblib/array.rb 2014-04-01 14:31:39 +09:00
Yukihiro "Matz" Matsumoto a85fdbdba4 according to JIS/ISO, Array is not Comparable 2014-03-31 00:50:16 +09:00
Yukihiro "Matz" Matsumoto 027d6407cc make Enumerable methods to support multiple values; collect, detect, each_with_index, find_all, inject, max, min, partition, reject, sort 2014-03-17 00:53:08 +09:00
Yukihiro "Matz" Matsumoto ed2fe64076 Enumerable#entries to support multiple values; close #1868 2014-03-17 00:34:47 +09:00
ksss bc63518fa7 modify core method that return Enumerator object if not block given 2014-03-15 08:15:04 +09:00
Yukihiro "Matz" Matsumoto 113ab60784 mruby-enumerator: move definitions in core_mod.rb to mrblib core 2014-03-14 02:41:22 +09:00
Yukihiro "Matz" Matsumoto 4a2c37df93 made mrb_define_class to return existing class, with heavy refactoring 2014-02-08 13:44:31 +09:00
Masaki Muranaka 6cd7017ec1 Remove trailing whitespaces. This is just a cosmetic change. 2013-03-03 10:54:00 +09:00
Yukihiro Matz Matsumoto c9c758d6ed fixed wrong loop termination introduced by 79d38c4 2013-01-18 15:43:35 +09:00
Yukihiro Matz Matsumoto 5166aa726d check if array expands in each block 2013-01-16 18:35:25 +09:00
Yukihiro Matz Matsumoto 79d38c4962 check if array shrinks in each block 2013-01-16 18:32:04 +09:00
Yukihiro Matz Matsumoto 55870e4b82 small refactoring for Array#each 2012-12-19 20:41:41 +09:00
Ryan Scott Lewis 6a450a6bda Update Array#each to be slightly faster. 2012-12-19 06:02:15 -05:00
Yoji SHIDARA aff4865f45 Fix a typo in comment
elment ->
element
2012-12-16 11:10:15 +09:00
Daniel Bovensiepen b584bb715b Modify documentation of Array 2012-05-06 18:15:02 +08:00
Daniel Bovensiepen 2c48bf4527 Add Documentation for Array 2012-05-02 21:19:00 +08:00
mimaki e0d6430f63 add mruby sources 2012-04-20 09:39:03 +09:00