Nobuyoshi Nakada
0cdad3b92a
Add `RUBY_REFERENCES`
...
Instead of `RUBY_REFERENCES_START` and `RUBY_REFERENCES_END`, so that
auto-indent works well.
2023-11-30 21:39:28 +09:00
Nobuyoshi Nakada
30f7b7a053
Prefix `REF_EDGE` and `REFS_LIST_PTR` with `RUBY_`
...
Also move `struct` so that `typedef`-ed names can be used.
2023-11-30 21:39:28 +09:00
Peter Zhu
db7f3064a8
Implement proc_entry on VWA
2023-11-29 22:51:13 -05:00
Peter Zhu
40e67cb20e
Implement Write Barriers on proc_entry
2023-11-29 22:51:13 -05:00
Peter Zhu
705a3c69d7
Add RUBY_TYPED_FREE_IMMEDIATELY flag to proc_entry
2023-11-29 22:51:13 -05:00
Peter Zhu
2e4a0a4d90
Implement Write Barriers on Enumerator::Producer
2023-11-27 08:29:35 -05:00
Peter Zhu
2dadd17c78
Implement Write Barriers on Enumerator::Generator
2023-11-27 08:29:35 -05:00
Peter Zhu
d7165d88ec
Implement Write Barriers on Enumerator::Yielder
2023-11-27 08:29:35 -05:00
Peter Zhu
315240e73b
Implement Write Barriers on Enumerator
2023-11-23 13:23:29 -05:00
Matt Valentine-House
cdc578ee00
Remove unneccesary defines in enumerator
2023-11-22 10:36:23 +00:00
Matt Valentine-House
a3f9a98c29
Remove unneccesary memsize functions in enumerator
2023-11-22 10:36:23 +00:00
Matt Valentine-House
1e075a734f
VWA Embed the rest of the data objects in Enumerator
2023-11-22 10:36:23 +00:00
Peter Zhu
a182b2c5e1
Implement Enumerator objects on VWA
...
This commit implements Enumerator objects on VWA. This speeds allocations
and decreases memory usage.
```
require "benchmark"
ary = []
puts(Benchmark.measure do
10_000_000.times do
u = ary.to_enum
end
end)
puts `ps -o rss= -p #{$$}`
```
Before:
```
1.500774 0.002717 1.503491 ( 1.506791)
18512
```
After:
```
0.892580 0.002539 0.895119 ( 0.897642)
16480
```
2023-11-20 18:59:01 -05:00
Hiroya Fujinami
3e64cf60b5
Fix [Bug #19632 ]: Disable external iterator for frozen enumerator ( #7791 )
...
* Fix [Bug #19632 ]: Disable external iterator for frozen enumerator
Currently, methods to manipulate an external iterator like `#next`
and `#feed` can be called even if a receiver of an enumerator is
frozen. However, these methods change the state of an external
iterator in an enumerator. Therefore, it seems a BUG to me, and
these methods should raise FrozenError if the receiver is frozen.
This fixed the following methods to raise FrozenError if the receiver is
frozen.
- `Enumerator#next`
- `Enumerator#next_values`
- `Enumerator#peek`
- `Enumerator#peek_values`
- `Enumerator#feed`
- `Enumerator#rewind`
* Fix a typo in the document
Thanks @Maumagnaguagno.
2023-10-25 16:32:25 +09:00
Marcelo Pereira
f15123c34c
Fix stack trace for rescued StopIteration
2023-07-15 15:24:43 +09:00
Jeremy Evans
a14915ca4b
Do not have Enumeratory::Lazy#zip mark result as packed
...
Fixes [Bug #19569 ]
2023-06-24 08:41:32 -07:00
Matt Valentine-House
22b349294b
Implement declarative references for enumerator
2023-03-17 19:20:40 +00:00
Benoit Daloze
d93d786338
Try to fix RDoc markup for Enumerator
2022-12-26 15:28:37 +01:00
Akinori MUSHA
cc4c28ec2e
Make Enumerartor.product return nil when called with a block
2022-12-21 19:13:15 +09:00
Akinori MUSHA
308ccbaeb2
Make product consistently yield an array of N elements instead of N arguments
...
Inconsistency pointed out by @mame:
```
>> Enumerator.product([1], [2], [3]).to_a
=> [[1, 2, 3]]
>> Enumerator.product([1], [2]).to_a
=> [[1, 2]]
>> Enumerator.product([1]).to_a
=> [1]
>> Enumerator.product().to_a
=> [nil]
```
Got fixed as follows:
```
>> Enumerator.product([1], [2], [3]).to_a
=> [[1, 2, 3]]
>> Enumerator.product([1], [2]).to_a
=> [[1, 2]]
>> Enumerator.product([1]).to_a
=> [[1]]
>> Enumerator.product().to_a
=> [[]]
```
This was due to the nature of the N-argument funcall in Ruby.
2022-12-21 18:19:19 +09:00
Benoit Daloze
33debffdd3
Use "Fiber storage variables" consistently
2022-12-20 23:05:56 +01:00
Benoit Daloze
4495dea153
Improve documentation for fiber-scoped variables
...
* Especially around Enumerator.
2022-12-20 23:05:56 +01:00
Benoit Daloze
45175962a6
Never use the storage of another Fiber, that violates the whole design
...
* See https://bugs.ruby-lang.org/issues/19078#note-30
2022-12-20 19:32:23 +01:00
Akinori MUSHA
ad18d1297e
Reject keyword arguments given to Enumerator::Product.new
...
The use of keyword arguments should be reserved for future extension.
2022-12-16 13:32:13 +09:00
Samuel Williams
0436f1e15a
Introduce `Fiber#storage` for inheritable fiber-scoped variables. ( #6612 )
2022-12-01 23:00:33 +13:00
Nobuyoshi Nakada
64c8ed272f
`remain` no longer starts with 0
2022-11-25 16:11:17 +09:00
Nobuyoshi Nakada
ffc6c5d056
[Bug #18971 ] Add precheck to enumerator
2022-11-25 16:11:17 +09:00
S-H-GAMELINKS
1f4f6c9832
Using UNDEF_P macro
2022-11-16 18:58:33 +09:00
Jeremy Evans
cfb9624460
Fix Array#[] with ArithmeticSequence with negative steps ( #5739 )
...
* Fix Array#[] with ArithmeticSequence with negative steps
Previously, Array#[] when called with an ArithmeticSequence
with a negative step did not handle all cases correctly,
especially cases involving infinite ranges, inverted ranges,
and/or exclusive ends.
Fixes [Bug #18247 ]
* Add Array#slice tests for ArithmeticSequence with negative step to test_array
Add tests of rb_arithmetic_sequence_beg_len_step C-API function.
* Fix ext/-test-/arith_seq/beg_len_step/depend
* Rename local variables
* Fix a variable name
Co-authored-by: Kenta Murata <3959+mrkn@users.noreply.github.com>
2022-08-11 19:16:49 +09:00
Nobuyoshi Nakada
58c8b6e862
Adjust styles [ci skip]
2022-08-06 10:13:20 +09:00
Akinori MUSHA
1a73a6cdd2
Implement Enumerator::Product and Enumerator.product [Feature #18685 ]
2022-07-30 20:05:14 +09:00
Takashi Kokubun
5b21e94beb
Expand tabs [ci skip]
...
[Misc #18891 ]
2022-07-21 09:42:04 -07:00
Nobuyoshi Nakada
f7ffe9dbde
Introduce `RBIMPL_NONNULL_ARG` macro
...
Runtime assertion for the argument declared as non-null.
This macro does nothing if `RBIMPL_ATTR_NONNULL` is effective,
otherwise asserts that the argument is non-null.
2021-09-27 14:47:52 +09:00
Nobuyoshi Nakada
8b48b57fd8
Comparing nonnull argument to NULL is useless
2021-09-23 16:55:35 +09:00
S-H-GAMELINKS
83a5e2bb5c
Using RB_FLOAT_TYPE_P macro
2021-09-12 11:16:31 +09:00
S-H-GAMELINKS
bdd6d8746f
Replace RBOOL macro
2021-09-05 23:01:27 +09:00
Nobuyoshi Nakada
e4f891ce8d
Adjust styles [ci skip]
...
* --braces-after-func-def-line
* --dont-cuddle-else
* --procnames-start-lines
* --space-after-for
* --space-after-if
* --space-after-while
2021-06-17 10:13:40 +09:00
Jeremy Evans
fd8991f797
Fix lazy enumerator with index size
...
Fixes [Bug #17889 ]
2021-05-27 14:17:32 -07:00
Jeremy Evans
9c31fb6114
Fix documentation for Enumerator::Lazy#with_index
...
If a block is given, it returns a lazy enumerator that will iterate
over the block, it doesn't iterate over the block immediately.
Fixes [Bug #17789 ]
2021-04-09 10:44:07 -07:00
Jeremy Evans
68d028578a
Undef Enumerator::Chain#{feed,next,next_values,peek,peek_values}
...
Previously these methods were defined but raised TypeError, which
seems worse.
2021-03-06 13:56:16 -08:00
Jeremy Evans
e1d16a9e56
Make Enumerator#{+,chain} create lazy chain if any included enumerator is lazy
...
Implements [Feature #17347 ]
2021-03-06 13:56:16 -08:00
Jeremy Evans
bf40fe9fed
Fix calling enumerator methods such as with_index on Enumerator::Chain
...
This previously raised a TypeError. Wrap the Enumerator::Chain in
an Enumerator to work around the problem.
Fixes [Bug #17216 ]
2021-03-06 13:56:16 -08:00
Masataka Pocke Kuwabara
391ee3ee3a
Replace `Kernel.#open` with `URI.open` in doc
...
Because `Kernel.#open` no longer opens URI since Ruby 3.0.
2021-01-08 07:31:27 -08:00
zverok
b8d33df1d9
Add Enumerable#compact and Enumerator::Lazy#compact
2021-01-02 17:27:24 +09:00
卜部昌平
fa356a798a
Enumerator.new: raise unless block given
...
Has been deprecated since c73b6bd7eb
.
[Feature #17116 ] [ruby-dev:50945]
2020-12-22 13:52:03 +09:00
Victor Shepelev
5253b9579a
Document usage of ArithmeticSequence in Array#slice, and add to NEWS ( #3952 )
2020-12-21 09:32:30 +09:00
Kenta Murata
fad3023e94
Fix ArithmeticSequence#last and ArithmeticSequence#each for non-integer sequences ( #3870 )
...
[Bug #17218 ]
[ruby-core:100312]
2020-12-09 18:48:59 +09:00
Nobuyoshi Nakada
4640c4ea8a
Removed more unnecessary ID caches
...
```
find . -name \*.o -exec nm {} + |&
grep -e 'InitVM_.*\.rbimpl_id' -e 'Init_.*\.rbimpl_id' |
sed 's/^.* b //;s/\.[1-9][0-9]*$//;s/\.rbimpl_id$//' |
uniq
```
should be empty.
2020-10-21 13:04:20 +09:00
Kenta Murata
a6a8576e87
Feature #16812 : Allow slicing arrays with ArithmeticSequence ( #3241 )
...
* Support ArithmeticSequence in Array#slice
* Extract rb_range_component_beg_len
* Use rb_range_values to check Range object
* Fix ary_make_partial_step
* Fix for negative step cases
* range.c: Describe the role of err argument in rb_range_component_beg_len
* Raise a RangeError when an arithmetic sequence refers the outside of an array
[Feature #16812 ]
2020-10-21 02:40:18 +09:00
卜部昌平
ff30358d13
RARRAY_AREF: convert into an inline function
...
RARRAY_AREF has been a macro for reasons. We might not be able to
change that for public APIs, but why not relax the situation internally
to make it an inline function.
2020-08-15 12:09:26 +09:00