John Bampton
de8a6fe787
Fix spelling
2024-07-13 00:21:53 +10:00
Yukihiro "Matz" Matsumoto
c75f7587bc
mruby-numeric-ext: add call-seq reference for Integer#size
2024-07-10 14:56:13 +09:00
Yukihiro "Matz" Matsumoto
ee296f024b
mruby-numeric-ext: add Integer#size method
...
Although CRuby uses clz() for the biggest word, mruby bigint only counts
number of digit words.
2024-07-10 14:50:54 +09:00
Yukihiro "Matz" Matsumoto
a77bc25a5f
mruby-sprintf: support dots expression of negative integer format
...
For specifiers assume unsigned integers, negative numbers show dots (..)
to indicate virtual infinite 1s at the MSB side of 2's compliment.
2024-07-09 11:13:55 +09:00
Yukihiro "Matz" Matsumoto
80fec16cb6
mruby-sprintf: inline sign_bits() function
2024-07-09 10:48:07 +09:00
Yukihiro "Matz" Matsumoto
d249c2e939
mruby-sprintf: separate filling high bits and converting negatives
2024-07-09 10:40:46 +09:00
Yukihiro "Matz" Matsumoto
2488375a35
mruby-bigint (mpz_mod): move mpz_init() to avoid memory leak
2024-07-09 08:00:23 +09:00
Yukihiro "Matz" Matsumoto
0ea1549faa
mruby-sprintf: reorder functions
...
In addition, internal function `mrb_str_format()` is made `static`.
2024-07-06 08:45:19 +09:00
Yukihiro "Matz" Matsumoto
bd502f6d7b
mruby-sprintf: support Big integers for %d etc.
2024-07-04 22:51:14 +09:00
Yukihiro "Matz" Matsumoto
f1a04dae3e
mruby-enum-ext (sort_by): avoid copying the receiver
...
When the receiver is an Array.
2024-07-03 07:31:32 +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
b9cb9b9bbe
Merge pull request #6295 from dearblue/revert-6282
...
Revert "Delegate the care of a directly given block from `cipop()` to `cipush()`"
2024-07-02 11:45:13 +09:00
dearblue
ad576f1e75
Revert "Delegate the care of a directly given block from cipop() to cipush()"
...
This reverts commit ad2e626e7a .
Because of the changes made by #6282 , the following code caused a problem.
```ruby
b = proc { break "BAD!" }
p self.tap { b.call }
# (expected) => break from proc-closure (LocalJumpError)
# (after #6282 ) => "BAD!"
```
I revived the `mrb_callinfo::blk` field to fix this, but it did not overcome the following problem.
```ruby
def m(&b); b = b.clone; GC.start; b.call; end
p m { break "OK!" }
# (expected) => "OK!"
# (revived blk) => break from proc-closure (LocalJumpError)
```
2024-06-30 21:01:45 +09:00
Yukihiro "Matz" Matsumoto
73337133f7
Merge pull request #6294 from auroranockert/optimise-obj-iv-p
...
Optimise `mrb_iv_get`
2024-06-30 18:25:43 +09:00
Yukihiro "Matz" Matsumoto
72bf46de22
array.c (mrb_ary_cmp): fixed wrong type casting
2024-06-30 18:19:52 +09:00
Yukihiro "Matz" Matsumoto
eee83ed7af
array.c: implement Array#index and Array#rindex in C
...
No need to override Array#index in mruby-array-ext. We can call
`to_enum` from C implemented methods.
2024-06-29 15:03:12 +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
Aurora Nockert
646c37ecda
Add a fast-path for mrb_type
...
By adding a fast-path where we ignore boxed types we can gain a pretty substantial speedup of mrb_iv_get, making it about 25% faster during a standard optcarrot benchmark run.
NOTE: It is just mrb_iv_get that is that much faster, the whole benchmark seems to be about 3-5% faster with word boxing.
2024-06-27 22:46:13 +02:00
Aurora Nockert
27f972b048
Reorder mrb_vtype
...
This allows the compiler to optimise the case in obj_iv_p into a range check. There does not seem to be any other very hot uses of this index and it grants a pretty big gain on optcarrot.
2024-06-27 22:46:13 +02:00
Yukihiro "Matz" Matsumoto
f709847bde
numeric.c (cmpnum): skip mrb_as_float() if possible
2024-06-27 10:02:06 +09:00
Yukihiro "Matz" Matsumoto
5b27469d19
numeric.c (mrb_cmp): check the first argument if it's int or float
...
To avoid the cost of `mrb_type(obj1)`.
2024-06-27 09:24:34 +09:00
Yukihiro "Matz" Matsumoto
ac1e4a2d58
numeric.c (cmpnum): handle the case where both arguments are fixnum first
...
To avoid the cost of `mrb_type(v2)`.
2024-06-27 08:55:28 +09:00
Yukihiro "Matz" Matsumoto
b8f968b4a3
numeric.c (mrb_cmp): no need to check respond_to?(:<=>)
...
Because every object responds to `<=>`.
2024-06-27 08:48:11 +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
Yukihiro "Matz" Matsumoto
b521d0816f
numeric.c (cmpnum): restrict comparison between Numeric objects
2024-06-25 14:36:56 +09:00
Yukihiro "Matz" Matsumoto
bb2733e9a2
numeric.c (cmpnum): rafactoring
...
- separate `MRB_NO_FLOAT` case
- use `mrb_as_float()` as much as possible
2024-06-24 09:34:13 +09:00
Yukihiro "Matz" Matsumoto
a0d4c63f9a
Merge pull request #6293 from dearblue/doc/opcode.md
...
Changed the instruction table in `opcode.md`
2024-06-23 20:14:51 +09:00
dearblue
f4f3a061be
Changed the instruction table in opcode.md
...
- Added the index number corresponding to the instruction code.
- Omitted trailing `|` from table elements.
The table elements in GitHub Flavored Markdown can't wrap wherever wanted.
And trying to align the end of it tends to make the whole thing longer.
2024-06-22 23:21:43 +09:00
Yukihiro "Matz" Matsumoto
54e99197bd
Revert "tools/lrama: apply ruby/lrama#442"
...
This reverts commit fb9fbc8498 .
The fix in the upstream still causes syntax error in C++.
2024-06-22 13:34:46 +09:00
Yukihiro "Matz" Matsumoto
eab6bddffe
Merge pull request #6292 from jbampton/pre-commit-autoupdate
...
markdownlint --fix; remove prettier; pre-commit autoupdate; fix spelling
2024-06-21 14:33:44 +09:00
Yukihiro "Matz" Matsumoto
d4c65d7ab1
AUTHORS: update entries [ci skip]
2024-06-21 13:01:38 +09:00
Yukihiro "Matz" Matsumoto
c592e7b70d
string.c: small refactoring
2024-06-21 10:11:32 +09:00
Yukihiro "Matz" Matsumoto
fb9fbc8498
tools/lrama: apply ruby/lrama#442
2024-06-21 08:12:27 +09:00
John Bampton
88e2eb0188
Fix spelling
2024-06-21 08:14:17 +10:00
John Bampton
06becc3495
pre-commit autoupdate
2024-06-21 08:14:17 +10:00
John Bampton
bbb0dddc7e
Remove prettier from pre-commit
2024-06-21 08:14:17 +10:00
John Bampton
ac74c90b30
Run markdownlint --fix
2024-06-21 06:53:42 +10:00
Yukihiro "Matz" Matsumoto
73c3970ea1
numeric.c: fix spacing in a comment
2024-06-19 09:25:19 +09:00
Yukihiro "Matz" Matsumoto
b8396aec33
numeric.c (cmpnum): fix a bug in float-bigint comparison
...
Should have used bigint to float conversion.
2024-06-19 09:25:19 +09:00
Yukihiro "Matz" Matsumoto
0f2d12a005
numeric.c (cmpnum): reduce else nesting
2024-06-18 01:50:49 +09:00
Yukihiro "Matz" Matsumoto
75de002058
mruby-complex: provide Complex#<=> in Ruby
2024-06-17 08:14:27 +09:00
Yukihiro "Matz" Matsumoto
3b9aec90dd
mruby-rational: define <=> method in Ruby, not in C
2024-06-17 08:02:42 +09:00
Yukihiro "Matz" Matsumoto
36eff3ec59
mruby-rational/test: remove UserDefinedNumeric tests
...
Since they checks the behavior different from CRuby.
2024-06-17 07:57:54 +09:00
Yukihiro "Matz" Matsumoto
d1592ba9f9
numeric.c (cmpnum): use mrb_as_int() instead of mrb_integer()
2024-06-17 07:51:25 +09:00
Yukihiro "Matz" Matsumoto
b44dc1c0b9
mruby-rational: use presym for initialization
2024-06-14 06:17:20 +09:00
Yukihiro "Matz" Matsumoto
0e045a52f6
mruby-complex: use presym for initialization
2024-06-14 06:15:34 +09:00
Yukihiro "Matz" Matsumoto
921a54ef33
mruby-socket/socket.rb: done some small refactoring
2024-06-14 06:14:27 +09:00
Yukihiro "Matz" Matsumoto
39d577799f
mruby-socket: use presym for initialization
2024-06-14 06:14:07 +09:00