Граф коммитов

353 Коммитов

Автор SHA1 Сообщение Дата
Jean Boussier 8c7e291dd8 Update references to flori/json
Now that the repository was transfered, these links will become
dead in a few months.
2024-10-07 20:12:57 -04:00
Jeremy Evans 9f574fa12f Make Complex#{inspect,to_s} work correctly if real part #inspect returns frozen string
Make static f_format function take a non-frozen string to append
to.

This does not result in an additional allocation for #inspect,
but it does result in an additional allocation for #to_s.

Fixes [Bug #20337]
2024-09-21 20:00:23 +02:00
BurdetteLamar ac85eef18b Fix links 2024-05-18 15:44:24 +09:00
Jean Boussier f06670c5a2 Eliminate usage of OBJ_FREEZE_RAW
Previously it would bypass the `FL_ABLE` check, but
since shapes introduction, it started having a different
behavior than `OBJ_FREEZE`, as it would onyl set the `FL_FREEZE`
flag, but not update the shape.

I have no indication of this causing a bug yet, but it seems
like a trap waiting to happen.
2024-04-16 17:20:35 +02:00
Jean Boussier d4f3dcf4df Refactor VM root modules
This `st_table` is used to both mark and pin classes
defined from the C API. But `vm->mark_object_ary` already
does both much more efficiently.

Currently a Ruby process starts with 252 rooted classes,
which uses `7224B` in an `st_table` or `2016B` in an `RArray`.

So a baseline of 5kB saved, but since `mark_object_ary` is
preallocated with `1024` slots but only use `405` of them,
it's a net `7kB` save.

`vm->mark_object_ary` is also being refactored.

Prior to this changes, `mark_object_ary` was a regular `RArray`, but
since this allows for references to be moved, it was marked a second
time from `rb_vm_mark()` to pin these objects.

This has the detrimental effect of marking these references on every
minors even though it's a mostly append only list.

But using a custom TypedData we can save from having to mark
all the references on minor GC runs.

Addtionally, immediate values are now ignored and not appended
to `vm->mark_object_ary` as it's just wasted space.
2024-03-06 15:33:43 -05:00
Kenta Murata 54a5b82944
Handle zero-like imaginary part as zero in to_r (#9581)
Fixes [Bug #5179]
2024-02-27 09:37:03 +09:00
Nobuyoshi Nakada dc146babf4 [Bug #20296] Clear errinfo when `exception: false` 2024-02-26 11:56:38 +09:00
Takashi Kokubun 38bf622cdc
Fix -Wmaybe-uninitialized on Complex#** (#10075) 2024-02-22 23:28:46 +00:00
Peter Zhu 7256e38f86 Replace assert with RUBY_ASSERT in complex.c
assert does not print the bug report, only the file and line number of
the assertion that failed. RUBY_ASSERT prints the full bug report, which
makes it much easier to debug.
2024-02-12 15:07:47 -05:00
Nobuyoshi Nakada 361b3efe16
Use `UNDEF_P` 2024-01-30 14:48:59 +09:00
Burdette Lamar 0990270c38
[DOC] Add What's Here for Complex (#9366) 2023-12-28 09:33:06 -05:00
BurdetteLamar 17e1d8ca62 RDoc for Complex 2023-12-26 11:27:31 -05:00
BurdetteLamar 901359559b RDoc for complex.c 2023-12-25 22:07:44 -05:00
BurdetteLamar 86ef38194b RDoc for complex.c 2023-12-24 14:56:06 -05:00
BurdetteLamar 8ad8803bb4 RDoc for Complex 2023-12-24 11:00:30 -05:00
Burdette Lamar 9b289d58f7
[DOC] RDoc for Complex (#9307) 2023-12-22 22:31:18 -05:00
BurdetteLamar f0b86f8c60 RDoc for Complex 2023-12-19 17:29:09 -05:00
BurdetteLamar 084b44e79d RDoc for Complex 2023-12-19 14:30:33 -05:00
Burdette Lamar f907a7111c
[DOC] RDoc for Complex (#9260) 2023-12-18 21:40:58 -05:00
Burdette Lamar 655c02790e
[DOC] RDoc for Complex (#9254) 2023-12-15 13:32:32 -05:00
Burdette Lamar 10a0545b6e
[DOC] RDoc for Complex (#9243) 2023-12-15 09:39:12 -05:00
Burdette Lamar 247ce712fc
[DOC] RDoc for Complex (#9231) 2023-12-14 11:09:17 -05:00
BurdetteLamar 18a5b6b7e9 [DOC] RDoc for Complex 2023-12-12 17:32:59 -05:00
Burdette Lamar e1d995a96c
[DOC] Complex doc (#9185) 2023-12-11 15:38:16 -05:00
Nobuyoshi Nakada 655aacc43a Use dedicated functions to check terminators 2023-12-11 16:51:46 +09:00
Burdette Lamar 91b0d5fa38
[DOC] RDoc for Complex (#9181) 2023-12-10 10:22:22 -05:00
BurdetteLamar 9e7ca2c3c9 RDoc for Complex 2023-12-08 15:13:11 -05:00
BurdetteLamar f76881c9af RDoc for Complex 2023-12-07 16:34:41 -05:00
Yusuke Endoh 31517c8627 Prevent a compiler warning: ‘zi’ may be used uninitialized 2023-11-22 13:07:44 +09:00
Kouhei Yanagita 04eb40b633 [Bug #11183] Fix rb_complex_pow for special angles
Add a special treatment for when the argument of self is an
integral multiple of 45 degrees.

  1i ** (10 ** 100)         #=> 1+0i
  1i ** (10 ** 100 + 1)     #=> 0+1i
  (1+1i) ** (10 ** 100)     # warning: in a**b, b may be too big
                            #=> (Infinity+0.0i)
  (1+1i) ** (10 ** 100 + 1) # warning: in a**b, b may be too big
                            #=> (Infinity+Infinity*i)
2023-11-21 14:06:26 +09:00
Matt Valentine-House 026321c5b9 [Feature #19474] Refactor NEWOBJ macros
NEWOBJ_OF is now our canonical newobj macro. It takes an optional ec
2023-04-06 11:07:16 +01:00
Burdette Lamar 1a8a24a633
[DOC] Enhanced RDoc for NilClass (#7500) 2023-03-13 12:55:59 -04:00
Nobuyoshi Nakada c0dc717c45 [Bug #19087] Disallow successive underscores in Complex string 2022-12-02 01:35:45 +09:00
S-H-GAMELINKS 1f4f6c9832 Using UNDEF_P macro 2022-11-16 18:58:33 +09:00
S.H c6f439a6a8
Improve performance some `Integer` and `Float` methods [Feature #19085] (#6638)
* Improve some Integer and Float methods

* Using alias and Remove unnecessary code

* Remove commentout code
2022-10-27 09:13:16 -07:00
Nobuyoshi Nakada 86450d03a8 Reduce type check of arguments at Complex creation 2022-10-23 16:44:43 +09:00
Stephen Ierodiaconou 54cad3123a
[Bug #19004] `Complex.polar` handles complex singular `abs` argument
`Complex.polar` accepts Complex values as arguments for the polar form as long
as the value of the complex has no imaginary part (ie it is 'real'). In
`f_complex_polar` this is handled by extracting the real part of the arguments.
However in the case `polar` is called with only a single argument, the absolute
value (abs), then the Complex is created without applying a check on the type
of abs, meaning it is possible to create a Complex where the real part is itself
an instance of a Complex. This change removes the short circuit for the single
argument case meaning the real part extraction is performed correctly
(by f_complex_polar).

Also adds an example to `spec/ruby/core/complex/polar_spec.rb` to check that
the real part of a complex argument is correctly extracted and used in the
resulting Complex real and imaginary parts.
2022-10-23 12:59:06 +09:00
Nobuyoshi Nakada 7cf37a5722
[DOC] Add the polar form in String#to_c 2022-10-17 12:02:34 +09:00
Nobuyoshi Nakada b5cf356447 Consider Complex from Complex cases
The assertions that "an argument of a Complex constructor must not be
a Complex" may not hold for some Numeric objects.
2022-09-02 14:33:23 +09:00
Nobuyoshi Nakada 9212d96307 [Bug #18937] Coerce non-real non-Numeric into Complex at comparisons 2022-09-02 14:33:23 +09:00
Nobuyoshi Nakada a9b59e24f4 Turn `f_zero_p` to `bool` 2022-09-02 14:33:23 +09:00
Nobuyoshi Nakada d5f50463c2
[Bug #18937] Coerce non-Numeric into Complex at comparisons 2022-08-22 12:26:43 +09:00
Kouhei Yanagita 24e33b84b5 Remove Numeric#ceildiv 2022-08-12 15:57:52 +09:00
Kouhei Yanagita 4165fd0e76 Add Numeric#ceildiv and Integer#ceildiv 2022-08-12 15:57:52 +09:00
Takashi Kokubun 5b21e94beb Expand tabs [ci skip]
[Misc #18891]
2022-07-21 09:42:04 -07:00
Nobuyoshi Nakada 16fdc1ff46
[DOC] Fix broken links to literals.rdoc 2022-02-08 01:27:52 +09:00
Nobuyoshi Nakada bc5662d9d8
[DOC] Simplify links to global methods 2022-02-08 01:18:56 +09:00
Burdette Lamar 28fb6d6b9e
Adding links to literals and Kernel (#5192)
* Adding links to literals and Kernel
2021-12-03 07:12:28 -06:00
Nobuyoshi Nakada 59bec48e48
Remove declarations unused since a95262356e 2021-10-18 23:46:58 +09:00
S.H b8c3a84bdd
Refactor and Using RBOOL macro 2021-09-15 08:11:05 +09:00