Yukihiro "Matz" Matsumoto
45078d9a49
mruby-string-ext: fixed typo (casecmp! -> casecmp?)
2024-07-17 02:25:49 +09:00
Yukihiro "Matz" Matsumoto
ac8846dbce
numeric.c: add Numeric#fdiv
2024-07-15 22:16:52 +09:00
Yukihiro "Matz" Matsumoto
301242c822
numeric.c (int_fdiv): add Integer#fdiv and Float#fdiv
2024-07-15 22:16:52 +09:00
Yukihiro "Matz" Matsumoto
4faab0581e
Merge pull request #6302 from auroranockert/minor-mrb-str-init-cleanup
...
Minor cleanup in mrb_str_init
2024-07-15 21:38:48 +09:00
Yukihiro "Matz" Matsumoto
ca28e639c6
mruby-numeric-ext: move allbits?, anybits?, nobits? to Integer class
2024-07-15 21:35:42 +09:00
Yukihiro "Matz" Matsumoto
3f5138a6ac
mruby-numeric-ext: implement Numeric#integer? method
2024-07-15 21:35:42 +09:00
Yukihiro "Matz" Matsumoto
1a8df40392
mruby-enum-ext: add Array#sort_by! method
2024-07-15 21:35:42 +09:00
Yukihiro "Matz" Matsumoto
fcab7ef377
numeric.c (int_div): fixed a bug regarding bigint / non-integer
...
Non-integer means Complex or Rational.
2024-07-15 21:35:42 +09:00
Yukihiro "Matz" Matsumoto
bcba0bc674
Merge pull request #6300 from jbampton/fix-spelling
...
Fix spelling
2024-07-15 21:35:43 +09:00
Aurora Nockert
a871e4908f
Minor cleanup in mrb_str_init
...
mrb_str_new was essentially manually inlined here, and I think it is a bit easier to follow if we just call the function instead.
2024-07-13 15:38:14 +02:00
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