| Age | Commit message (Collapse) | Author |
|
Make "N for M" into the form "given N, expected M".
As I worked, I noticed that the `argnum_error()` function had a part to include the method name in the message.
I think this part is no longer needed by https://github.com/mruby/mruby/pull/5394.
- Before this patch
```console
% bin/mruby -e '[1, 2, 3].each 0'
trace (most recent call last):
[1] -e:1
-e:1:in each: 'each': wrong number of arguments (1 for 0) (ArgumentError)
```
- After this patch
```console
% bin/mruby -e '[1, 2, 3].each 0'
trace (most recent call last):
[1] -e:1
-e:1:in each: wrong number of arguments (given 1, expected 0) (ArgumentError)
```
|
|
* should not raise error for non-string arguments
* avoid allocating case converted string internally
|
|
|
|
```console
% for rb in `git ls-files '*/mrblib/*.rb' 'mrblib'`; do ruby30 -cw $rb > /dev/null; done
mrbgems/mruby-array-ext/mrblib/array.rb:389: warning: assigned but unused variable - ary
mrbgems/mruby-array-ext/mrblib/array.rb:663: warning: assigned but unused variable - len
mrbgems/mruby-hash-ext/mrblib/hash.rb:119: warning: possibly useless use of a variable in void context
mrbgems/mruby-hash-ext/mrblib/hash.rb:259: warning: assigned but unused variable - keys
mrbgems/mruby-io/mrblib/io.rb:229: warning: literal in condition
mrbgems/mruby-io/mrblib/io.rb:280: warning: literal in condition
mrbgems/mruby-string-ext/mrblib/string.rb:347: warning: assigned but unused variable - len
mrbgems/mruby-toplevel-ext/mrblib/toplevel.rb:2: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument
```
|
|
|
|
|
|
When the receiver is the instance of subclass of `String`.
- `String#each_char`
- `String#each_line`
- `String#partition`
|
|
zubycz-work_for_merge
|
|
Co-Authored-By: n4o847 <[email protected]>
Co-Authored-By: smallkirby <[email protected]>
|
|
Co-authored-by: taiyoslime <[email protected]>
Co-authored-by: smallkirby <[email protected]>
|
|
Currently, `Integral#chr` in mruby changes behavior by `MRB_UTF8_STRING`
setting.
before this patch:
$ bin/mruby -e 'p 171.chr' #=> "\xab" (`MRB_UTF8_STRING` is disabled)
$ bin/mruby -e 'p 171.chr' #=> "«" (`MRB_UTF8_STRING` is enabled)
This behavior is incompatible with Ruby, and a little inconvenient because
it can't be interpreted as ASCII-8BIT with `MRB_UTF8_STRING`, I think.
So add encoding argument according to Ruby.
after this patch:
$ bin/mruby -e 'p 171.chr' #=> "\xab"
$ bin/mruby -e 'p 171.chr("ASCII-8BIT")' #=> "\xab"
$ bin/mruby -e 'p 171.chr("UTF-8")' #=> "«"
Allow only `String` for encoding because mruby doesn't have `Encoding`
class, and `"ASCII-8BIT"` (`"BINARY"`) and `"UTF-8"` (only with
`MRB_UTF8_STRING`) are valid value (default is `"ASCII-8BIT"`).
|
|
|
|
|
|
Because `try_convert` method rarely used in production. For mruby users,
we have `__to_str` utility method to check string type.
|
|
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.
|
|
Avoid using `mrb_yield` in C code. The function is not recommended.
Because it doesn't work well with fibers.
|
|
`String#lines` (with a block) is now implemented in Ruby.
|
|
`FrozenError` is a subclass of `RuntimeError` which used to be
raised. [Ruby2.5]
|
|
|
|
|
|
|
|
|
|
|
|
- String#ljust and String#rjust are now C functions to improve performance
- infinite loop because of an empty padding argument is now prevented (ArgumentError is raised)
- extra tests for ljust/rjust added
|
|
Fix #3357
|
|
|
|
|
|
Here are some benchmarks:
each_char:
# /tmp/each_char.rb
a = "a" * 1000000
a.each_char do |x|
end
Without this change:
% time bin/mruby /tmp/each_char.rb
bin/mruby /tmp/each_char.rb 1.07s user 0.02s system 99% cpu 1.088 total
With this change:
% time bin/mruby /tmp/each_char.rb
bin/mruby /tmp/each_char.rb 0.52s user 0.01s system 99% cpu 0.530 total
2 times faster with this change.
codepoints:
# /tmp/codepoints.rb
a = "a" * 1000000
a.codepoints do |x|
end
Without this change:
% time bin/mruby /tmp/codepoints.rb
bin/mruby /tmp/codepoints.rb 1.16s user 0.05s system 99% cpu 1.216 total
With this change:
% time bin/mruby /tmp/codepoints.rb
bin/mruby /tmp/codepoints.rb 0.56s user 0.02s system 99% cpu 0.589 total
|
|
|
|
|
|
|
|
|
|
define MRB_UTF8_STRING (in mrbconf.h) to enable UTF-8 support.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Fix indent in String#casecmp comments
|
|
|
|
strip_bang
|
|
when non String object sent
And should be raise TypeError
when can not responsed to `to_str`
|
|
|
|
|
|
|