summaryrefslogtreecommitdiffhomepage
path: root/mrblib
AgeCommit message (Collapse)Author
2020-06-20Move definition of `BasicObject#!=` to `mrblib`.Yukihiro "Matz" Matsumoto
C implementation used `mrb_funcall()` that bypassed many optimization.
2020-05-09Fix some `Hash` methods are inconsistent with `values`KOBAYASHI Shuji
Inconsistent when hash has duplicate key. ### Example ```ruby # example.rb keys = (1..3).map{[_1]} h = keys.to_h{[_1, _1[0]]} keys[0][0] = 2 p h.values p h.each_value.to_a p h ``` #### Before this patch: ```console $ bin/mruby example.rb [1, 2, 3] [1, 1, 3] {[2]=>1, [2]=>1, [3]=>3} ``` #### After this patch (same as Ruby) ```console $ bin/mruby example.rb [1, 2, 3] [1, 2, 3] {[2]=>1, [2]=>2, [3]=>3} ```
2019-12-27Use Rake DSL instead of commands of `FileUtils`KOBAYASHI Shuji
- Respect `--verbose(-v)` and `--dry-run(-n)` options. - Silence warnings to keyword arguments on Ruby 2.7.
2019-09-12Merge pull request #4527 from lopopolo/string-each-line-paragraph-modeYukihiro "Matz" Matsumoto
Add paragraph mode to String#each_line in mrblib
2019-08-17Implement `Array#each` using inline mruby bytecode.Yukihiro "Matz" Matsumoto
2019-08-16Implement `Class#new` using inline mruby bytecode.Yukihiro "Matz" Matsumoto
2019-08-14Integrate `kazuho/mruby-class-new-fiber-safe` in the master.Yukihiro "Matz" Matsumoto
Avoid calling `initialize` via `mrb_funcall`, which cause `cross C boundary` error from Fibers started in the method.
2019-08-10`Enumerable#reject`, etc. should return `Enumerable` without blockKOBAYASHI Shuji
2019-07-17Fixed a bug in #4034Yukihiro "Matz" Matsumoto
2019-07-17Merge branch 'master' into i110/inspect-recursionYukihiro "Matz" Matsumoto
2019-07-13`Enumerable#detect` {and `#find`} should call `ifnone`; fix #4484Yukihiro "Matz" Matsumoto
It's an error in ISO specification; 15.3.2.2.4 and 15.3.2.2.7
2019-07-07Fix `Numeric#step` to infinity; ref. #4555KOBAYASHI Shuji
2019-06-29Replace `String#[]=` method by C implementsdearblue
The purpose is to eliminate string objects that are temporarily created during processing.
2019-06-25Unify loops to minimize bytecode sizeRyan Lopopolo
2019-06-23Use explicit block parameterRyan Lopopolo
2019-06-23Optimize String#each_lineRyan Lopopolo
2019-06-22Speed up base case by 2xRyan Lopopolo
Make non-paragraph mode twice as fast. Performance is within a factor of 2 of the original implementation.
2019-06-22Add paragraph mode to String#each_line in mrblibRyan Lopopolo
mruby/mruby#4511 demonstrated an infinite loop in `String#each_line` when given an empty string separator. In MRI, an empty separator places String#each_line in paragraph mode, where the String is separated on successive runs of newlines. In paragraph mode, the String `"abc\n\n\ndef\nxyz"` is split into `["abc\n\n\n", "def\nxyz"]`. This commit makes the String#each_line implementation as close to ruby/spec compliant as possible given the limitations of mruby core. With this patch, the following specs fail for `String#each_line`: - uses `$/` as the separator when none is given (can be fixed by aliasing and redefining the method to use $/ as the default value of separator in mruby-io) - when no block is given returned Enumerator size should return nil (`Enumerator#size` is not supported on mruby) - tries to convert the separator to a string using to_str (`String#to_str` is not implemented on mruby) This patch has similar memory consumption compared to the prior implementation and is takes 4x the time the prior implementation takes to execute: ```console /usr/bin/time -l ./bin/mruby -e '("aaa\n\nbbbbb\n\n\n\n\ncccc" * 100000).each_line("\n") { }'; ```
2019-06-04Fix typo in `mrblib/range.rb` [ci skip]KOBAYASHI Shuji
2019-05-15Add Enumerator support to `String#each_byte`.Yukihiro "Matz" Matsumoto
`String#each_byte` is not defined in ISO Ruby but it is implemented in the core mruby because it's useful.
2019-05-15Remove `String#=~` and `String#match` that requires `Regexp`.Yukihiro "Matz" Matsumoto
2019-04-27Remove duplicated `String#each_char`KOBAYASHI Shuji
2019-04-21Commented out `String#scan` because it is not implemented yetKOBAYASHI Shuji
2019-04-19Add type check (conversion) in `String#[]=`KOBAYASHI Shuji
Before this patch: 'a'[0] = 1 #=> 1 'a'[:a] = '1' #=> ArgumentError 'a'[:a, 0] = '1' #=> ArgumentError 'a'[0, :a] = '1' #=> ArgumentError 'a'[0, 1] = 1 #=> 1 After this patch / Ruby: 'a'[0] = 1 #=> TypeError 'a'[:a] = '1' #=> TypeError 'a'[:a, 0] = '1' #=> TypeError 'a'[0, :a] = '1' #=> TypeError 'a'[0, 1] = 1 #=> TypeError
2019-04-18Remove duplicated `include Comparable` in `mrblib/string.rb`KOBAYASHI Shuji
2019-04-08Avoid infinite loop when no `Regexp` class is available; fix #4363Yukihiro "Matz" Matsumoto
2019-03-02Raise error on failed comparison in `sort`; ref #4307Yukihiro "Matz" Matsumoto
2019-02-01Move `NONE` to `mrblib/enum.rb`KOBAYASHI Shuji
2019-01-16Avoid runtime evaluation for `MRB_WITHOUT_FLOAT`KOBAYASHI Shuji
2019-01-15Fix coercing for first step counter in `Numeric#step`KOBAYASHI Shuji
Before: a=[]; 7.step(4, -3.0) { |c| a << c }; p a #=> [7, 4.0] After / Ruby: a=[]; 7.step(4, -3.0) { |c| a << c }; p a #=> [7.0, 4.0]
2019-01-04Integrate mrblib/float.rb into src/numeric.cKOBAYASHI Shuji
- Avoid hack for `MRB_WITHOUT_FLOAT` in build scripts - Avoid runtime dispatch for `MRB_WITHOUT_FLOAT`
2019-01-03Remove `Kernel#class_defined?` which is not available in CRuby; #3829Yukihiro "Matz" Matsumoto
2018-11-19Avoid assignments from type checking `String#__to_str`.Yukihiro "Matz" Matsumoto
2018-11-19Removed `to_hash` conversion method.Yukihiro "Matz" Matsumoto
2018-11-19Remove implicit conversion using `to_str` method; fix #3854Yukihiro "Matz" Matsumoto
We have added internal convenience method `__to_str` which does string type check. The issue #3854 was fixed but fundamental flaw of lack of stack depth check along with fibers still remains. Use `MRB_GC_FIXED_ARENA` for workaround.
2018-11-19Remove implicit conversion using `to_int` method.Yukihiro "Matz" Matsumoto
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-10-29Rename libmruby stuff to avoid confusiontake-cheeze
2018-10-29Re-implement `Array#_inspect` and `Hash#_inspect` without blocks.Yukihiro "Matz" Matsumoto
To reduce the env object allocation; ref #4143
2018-10-18replace quicksort with mergesort.Tomoyuki Sahara
2018-09-26Implement `Hash#rehash` in C using `sg_compact()`.Yukihiro "Matz" Matsumoto
2018-09-26Add index to larger segment lists for performanceYukihiro "Matz" Matsumoto
2018-09-26Use `mrb_undef_value` for delete mark instead of shifting Hash entry table.Yukihiro "Matz" Matsumoto
That means entry table should be compacted periodically by `sg_compact()`.
2018-09-20Move `Symbol#to_proc` to the core from `mruby-symbol-ext` gem.Yukihiro "Matz" Matsumoto
Even though `Symbol#to_proc` is not included in ISO standard, the `some_method(&:method_name)` is used very widely and convenient. So we moved it to the core.
2018-09-01Fix ISO/JIS section numbers.Yukihiro "Matz" Matsumoto
2018-08-25Remove unused `Hash#__update` method.Yukihiro "Matz" Matsumoto
2018-08-25Make `Array.new` to accept both integers and floats.Yukihiro "Matz" Matsumoto
This time we used `Integral` module which is mruby specific.
2018-08-25Fixed the corner case bug in `String#{gsub!,sub!}`.Yukihiro "Matz" Matsumoto
`"a".sub!("a", "a")` should not return `nil`.
2018-06-04Let inspect recursion do the right thingIchito Nagata
2018-06-01let Hash#merge keep ifnone valueIchito Nagata
2018-04-28Update the patch to not use `funcall` in C; ref #4013Yukihiro "Matz" Matsumoto