Yukihiro "Matz" Matsumoto
95b30a38dc
kernel.rb: make Kernel#loop private
2025-03-07 17:17:44 +09:00
Yukihiro "Matz" Matsumoto
541cdf35eb
00kernel.rb: use #__send__ to skip private check
2025-03-07 17:17:41 +09:00
Yukihiro "Matz" Matsumoto
798fd7dbdf
00class.rb: use #__send__ to skip private check
2025-03-07 17:17:41 +09:00
Yukihiro "Matz" Matsumoto
4122cee9e4
class.c: implement attr_accessor in C
2025-03-07 17:17:39 +09:00
dearblue
a7a81aa761
Storing method-id inside Symbol#to_proc
...
When called in combination with a method like `*_eval` or `*_exec` that switches self, `__send__` was passed an object that was not necessarily a symbol as the method name.
This problem was discovered during the #6389 correction process.
2024-10-27 10:41:51 +09:00
Yukihiro "Matz" Matsumoto
e8bb03da40
numeric.rb (step): iterate over integers even if end is a float
...
It used to check all `start`, `end` and `step`. If either of them are
float number, `#step` iterated over float number. Now we don't check the
type of `end` argument.
2024-08-03 13:35:09 +09:00
Yukihiro "Matz" Matsumoto
7c7ee5c244
array.c: implement Array#delete method in C
2024-07-02 11:45:20 +09:00
Yukihiro "Matz" Matsumoto
dd808a0be4
array.c: implement Array#<=> in C
2024-06-29 15:03:12 +09:00
Yukihiro "Matz" Matsumoto
8cffa04def
array.c: implement Array#== and Array#eql? in C
...
It seems OK to call comparison from C method from measurement.
2024-06-29 08:32:06 +09:00
Yukihiro "Matz" Matsumoto
5b8de8d616
Array.c (mrb_ary_init): implement Array#initialize in C
2024-06-28 08:56:41 +09:00
Yukihiro "Matz" Matsumoto
5bd63d6232
array.c: replace sort! method implementation
...
- use heap sort (O(1)) instead of merge sort (O(n)) for better space
complexity.
- method implemented in C for better performance
As a result, simple sorting now consumes far less memory and is faster.
Since it's implemented in C, fiber context switching is not allowed from
comparison, but we consider the risk is minimal (no one switches context
in the comparison, right?)
2024-06-26 11:28:56 +09:00
dearblue
f0cd35c78b
Passes the nonexistent key as a block argument in Array#delete
...
```ruby
a = %w(R G B A)
p a.delete("Y") { _1 }
# BEFORE => nil (same for mruby 3.3)
# AFTER => "Y" (same for CRuby)
```
2024-05-10 22:46:11 +09:00
leviongit
67df0aca67
fix: Array#delete mistakingly calling block even if not passed
2024-05-09 14:33:23 +02:00
leviongit
bb78c2cbc9
reimplement Array#delete with a helper method
2024-04-13 07:41:00 +02:00
leviongit
312d49c59f
reimplement Array#delete in ruby
2024-04-13 07:21:51 +02:00
leviongit
c04afb9e99
revert moving Array#delete to c
2024-04-13 06:52:37 +02:00
leviongit
14bd875d70
fix Array#delete
...
reimplement `Array#delete` in c, fixing `ary.delete(nil, &blk)` firing the block regardless of removal
minimal reproduction:
```rb
ary = [nil]
ret = ary.delete(nil) { "not deleted?" }
```
2024-04-12 17:30:03 +02:00
Yukihiro "Matz" Matsumoto
fc9fffc5b5
kernel.rb (_inspect): _inspect method no longer needed
2023-06-22 23:32:31 +09:00
Yukihiro "Matz" Matsumoto
113565a1c5
hash.c (mrb_hash_to_s): add recursive inspect check to Hash#inspect
2023-06-20 11:18:38 +09:00
Yukihiro "Matz" Matsumoto
5cb0c7463b
array.c (mrb_ary_to_s): add recursive check to Array#inspect
2023-06-20 07:06:33 +09:00
Yukihiro "Matz" Matsumoto
89a1719a13
compar.rb: use equal?() instead of ==
...
To avoid unnecessary infinite recursion.
2023-06-19 15:33:13 +09:00
Yukihiro "Matz" Matsumoto
f5a7b6aad2
hash.rb: defer local variable initialization
2023-02-02 22:45:30 +09:00
Yukihiro "Matz" Matsumoto
ecd2d8c11e
wrap method arguments by parentheses as convention
2023-02-01 14:33:46 +09:00
Yukihiro "Matz" Matsumoto
6bc44f8aa8
Remove non-existent ISO section numbers suffixed with "(x)" [ci skip]
...
We don't know how we introduced these section references.
Weak memories.
2023-01-08 22:32:16 +09:00
John Bampton
ea8964ef35
ruby: standardize whitespace
2022-10-31 16:25:56 +10:00
John Bampton
44db4f18d3
Remove # coding: utf-8 from Ruby files
...
The default script encoding is Encoding::UTF-8 after v2.0.
https://ruby-doc.org/core-2.1.2/Encoding.html#class-Encoding-label-Script+encoding
2022-10-27 04:43:13 +10:00
Yukihiro "Matz" Matsumoto
abec98c681
numeric.c: implement ceil, floor, round, truncate methods in C.
...
- ISO 15.2.8.3.14 Integer#ceil
- ISO 15.2.8.3.17 Integer#floor
- ISO 15.2.8.3.20 Integer#round
- ISO 15.2.8.3.26 Integer#truncate
2022-08-10 13:38:23 +09:00
Yukihiro "Matz" Matsumoto
89f22158d3
string.rb (each_line): may truncate string by mistake; fix #5727
2022-06-24 13:25:45 +09:00
Yukihiro "Matz" Matsumoto
01392e2719
mrblib/array.rb: add call-seq to each method description. [ci skip]
2022-06-22 19:02:54 +09:00
Yukihiro "Matz" Matsumoto
981740b1f2
mrblib/compar.rb: add call-seq to each method description. [ci skip]
2022-06-22 19:02:48 +09:00
Yukihiro "Matz" Matsumoto
9a34bd9971
hash.rb: update Hash class documents [ci skip]
2022-06-20 12:19:54 +09:00
Yukihiro "Matz" Matsumoto
d2a24a540c
hash.c: implement typical part of merge in C.
2022-06-19 22:28:31 +09:00
Yukihiro "Matz" Matsumoto
14e5c0c7b9
hash.rb (merge): now takes multiple arguments.
2022-06-18 08:25:11 +09:00
Yukihiro "Matz" Matsumoto
038aa6beb2
strinc.rb (sub, gsub): use byte index instead of char index.
2022-05-19 10:14:59 +09:00
Yukihiro "Matz" Matsumoto
ce141b1332
string.rb (each_line): should not use [] reference.
...
Use `byteslice` instead.
2022-05-19 10:14:59 +09:00
Yukihiro "Matz" Matsumoto
f8b9464118
string.rb (each_line): use byteindex for performance; fix #4522
...
Character-wise String#index method calculate UTF-8 character width
numerous times if the string is long.
2022-05-17 07:18:44 +09:00
dearblue
76d3ea8458
Improvements to String#each_byte
...
Each byte value is now retrieved inside the loop.
2022-04-16 22:23:34 +09:00
Yukihiro "Matz" Matsumoto
91255c7e9f
mrblib/array.rb: Array#<=> to handle NoMethodError exception.
...
Array element may not respond to `<=>` method.
2022-03-26 22:57:41 +09:00
dearblue
75371b8831
Reimplement Exception#message in Ruby
...
Suppresses the possibility of `mrb_vm_exec()` being called recursively.
2022-03-13 18:56:23 +09:00
Yukihiro "Matz" Matsumoto
c2f7ed514d
Merge pull request #5663 from dearblue/include-prepend
...
Small improvements to `Module#{include,prepend}`
2022-03-07 18:57:25 +09:00
dearblue
ac0d27d1a9
Reimplement Kernel.extend in Ruby
2022-03-06 13:48:04 +09:00
dearblue
9d04183ce1
Small improvements to Module#{include,prepend}
...
Array objects obtained as splat arguments are generated within the method.
Therefore, it is safe to perform destructive operations.
2022-03-06 13:43:31 +09:00
dearblue
c4bca7cbb3
Align "wrong number of arguments" messages
...
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)
```
2021-11-28 18:21:29 +09:00
dearblue
16e388863a
Fixed some methods where keyword arguments are not passed
2021-11-24 23:35:42 +09:00
Yukihiro "Matz" Matsumoto
3622f2c4b5
string.c: implement __sub_replace() in C.
...
To reduce number of string allocation.
2021-09-01 07:00:55 +09:00
Yukihiro "Matz" Matsumoto
082882da69
string.rb: avoid internal __to_str calls.
...
`__to_str` was a mere type check method despite its name.
2021-09-01 07:00:55 +09:00
Yukihiro "Matz" Matsumoto
23e7cb41e5
Replace fixnum references with int.
...
The `Fixnum` class is no longer provided by `mruby`.
2021-08-03 13:00:10 +09:00
Yukihiro "Matz" Matsumoto
7fa0a704e0
Make LocalJumpError a direct subclass of StandardError.
...
To be compatible with CRuby.
2021-07-05 11:57:04 +09:00
Yukihiro "Matz" Matsumoto
364f275997
range.c: implement (part of) Range#to_a in C.
...
Mostly for performance reason.
2021-05-14 08:39:14 +09:00
Yukihiro "Matz" Matsumoto
5c7aa4f299
Simplify module inclusion for Array, Hash and Range.
2021-05-13 16:07:09 +09:00