aboutsummaryrefslogtreecommitdiffstats
path: root/enumerator.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix call-seq of lazy.filter_map [ci skip]Kazuhiro NISHIYAMA2019-06-211-3/+2
|
* * expand tabs.git2019-06-211-3/+3
|
* Lazy filter_mapNobuyoshi Nakada2019-06-211-0/+35
|
* [DOC] Improve documentation for Enumerator::LazyMarcus Stollsteimer2019-05-181-12/+12
|
* Static symbols can't be moved (they are not RValue)Aaron Patterson2019-05-141-11/+12
| | | | | | | | | This is my mistake, I thought they were regular objects, but apparently they are not. We don't need to pin them. Revert "Symbols can move so only cache IDs" This reverts commit 672ee5f6ed5a6840a3be9150b6721a5ee8f8766b.
* Symbols can move so only cache IDsAaron Patterson2019-05-141-12/+11
| | | | IDs can't move, we need to use them to look up the symbol objects later.
* Add `or nil` to call-seq of `Enumerator::ArithmeticSequence#begin`Kazuhiro NISHIYAMA2019-04-271-1/+1
| | | | | | | | | | | ``` % ruby -ve 'p (nil..).first' ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18] nil % ruby -ve 'p (nil..).begin' ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18] nil ```
* enumerator.c: force hash values fixablenobu2019-04-081-1/+1
| | | | | | | * enumerator.c (arith_seq_hash): force hash values fixable on LLP64 environment. [ruby-core:92190] [Bug #15755] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enumerator.c: make arith_seq_first support nil beginmrkn2019-04-041-0/+3
| | | | | | | | | * enumerator.c: (arith_seq_first): support nil begin. * test/ruby/test_arithmetic_sequence.rb (test_first): add assertions for beginless and endless arithmetic sequences. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add Enumerator::Lazy docs.hsbt2019-03-201-26/+221
| | | | | | | | | | | | | * explanation of the class concept, with examples; * docs for all class methods (most of them just say "Like Enumerable#<methodname>, but chains operation to be lazy-evaluated.", but I believe they are useful this way because now have proper call-sequences and link to corresponding Enumerable's explanations) * simplified example for ::new to emphasize the main concept * Enumerable#lazy docs are slightly lightened and linked to this class for more in-depth explanations. [Misc #15529][ruby-core:91046] Co-authored-by: zverok <zverok.offline@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Implement Enumerator::Yielder#to_procknu2019-03-111-2/+25
| | | | | | | | | | | | | | | A Yielder object can now be directly passed to another method as a block argument. ```ruby enum = Enumerator.new { |y| Dir.glob("*.rb") { |file| File.open(file) { |f| f.each_line(&y) } } } ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * expand tabs.svn2019-01-301-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66948 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enumerator.c: fix arith_seq_first for Infinitymrkn2019-01-301-10/+115
| | | | | | | | | | | | | | * enumerator.c (arith_seq_first): fix for Float::INFINITY. * test/ruby/test_arithmetic_sequence.rb: add tests. * numeric.c (ruby_float_step_size): export for internal use. * internal.h: add prototype declaration of ruby_float_step_size. [ruby-core:90937][Bug #15518] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enumerator.c: fix inspect with the last empty hashnobu2018-12-241-1/+1
| | | | | | [ruby-core:90685] [Bug #15455] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* range.c: reject ArithmeticSequence in rb_range_valuesmrkn2018-12-211-1/+1
| | | | | | | Reject ArithmeticSequence in rb_range_values so that methods like Array#[] raises TypeError for ArithmeticSequence as an index. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enumerator.c: Fix airth_seq_each for Rationalmrkn2018-12-211-2/+4
| | | | | | | | Fix the wrong uses of rb_int_ge in arith_seq_each. [ruby-core:90648] [Bug #15444] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enumerator.c: Add rb_arithmetic_sequence_components_tmrkn2018-12-121-9/+9
| | | | | | | Add rb_arithmetic_sequence_components_t struct for encapsulating the components of ArithmeticSequence. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enumerator.c: rb_arithmetic_sequence_extractmrkn2018-12-121-0/+21
| | | | | | | New public C-API for extracting components of Enumerator::ArithmeticSequence or Range. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Prefer rb_check_arity when 0 or 1 argumentsnobu2018-12-061-5/+2
| | | | | | | Especially over checking argc then calling rb_scan_args just to raise an ArgumentError. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* use RARRAY_AREF instead of RARRAY_PTR_USE.ko12018-12-031-28/+20
| | | | | | | | | | | | | * enumerator.c (enum_chain_total_size): use RARRAY_AREF instead of RARRAY_PTR_USE because we don't need non-const ptr. * enumerator.c (enum_chain_each): ditto. * enumerator.c (enum_chain_rewind): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add Float::INFINITY or nil to call-seq of Enumerator::Chain#size [ci skip]kazu2018-11-271-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enumerator.c (enum_chain_yield_block): use predefined IDnormal2018-11-271-1/+1
| | | | | | No point in having rb_intern lookup and cache a predefined ID git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Implement Enumerator#+ and Enumerable#chain [Feature #15144]knu2018-11-241-0/+314
| | | | | | | | | | | | | | | | They return an Enumerator::Chain object which is a subclass of Enumerator, which represents a chain of enumerables that works as a single enumerator. ```ruby e = (1..3).chain([4, 5]) e.to_a #=> [1, 2, 3, 4, 5] e = (1..3).each + [4, 5] e.to_a #=> [1, 2, 3, 4, 5] ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* avoid division by zeroshyouhei2018-11-161-5/+6
| | | | | | | | | | | | | | * cvt(): use signbit() instead of 1/d < 0 * w_float(): ditto * ruby_float_step_size(): unit==0 check shall be prior to divisions * arith_seq_float_step_size(): ditto * rb_big_divide(): same as r65642 * fix_divide(): ditto * rb_big_fdiv_double(): ditto * fix_fdiv_double(): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * expand tabs.svn2018-10-221-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Set the size of a new enumerator created by Enumerator#each with arguments ↵knu2018-10-221-0/+2
| | | | | | | | | | | to nil When each() takes arguments, it is never safe to assume that the iteration would repeat the same number of times as with each() without any argument. Actually, there is no way to get the exact number, so the size should be set to nil to denote that. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enumerator.c: [DOC] small fixstomar2018-10-121-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Lazy Enumerator reduce intermediate array creationnobu2018-09-181-12/+16
| | | | | | | | [ruby-core:87907] [Bug #14908] [Fix GH-1912] From: Anmol Chopra <chopraanmol1@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] aseq.each always return self [ci skip]kazu2018-09-121-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] Add the documentation of ArithmeticSequencemrkn2018-09-121-0/+82
| | | | | | [ci-skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enumerator.c: Fix ArithmeticSequence for complex stepmrkn2018-09-121-1/+1
| | | | | | | | | Make sure Enumerator::ArithmeticSequence#each to work well for a complex step value. This reverts commit ca47fb329a1d48af3e1009620bdb18e931c9f188. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "enumerator.c: Fix ArithmeticSequence for complex step"mrkn2018-09-121-2/+1
| | | | | | This reverts commit 0a0f8238d02a2dfff4cd2892408e14cb826cec7e. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enumerator.c: Fix ArithmeticSequence for complex stepmrkn2018-09-121-1/+2
| | | | | | | Make sure Enumerator::ArithmeticSequence#each to work well for a complex step value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enumerator.c: [DOC] Enumerator::Lazy#force [ci skip]nobu2018-09-051-0/+17
| | | | | | | added documentation of Enumerator::Lazy#force, just to clarify that it is an alias of an inherited method. [ruby-core:88872] [Bug #15079] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Remove extra semicolonkazu2018-08-201-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Adding Enumerator::Lazy#uniq and Enumerator::Lazy#grep_v to proc chainingnobu2018-08-161-45/+53
| | | | | | | | | | [Feature #14994] [Fix GH-1930] From: Anmol Chopra <chopraanmol1@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enumerator.c: id_lazy is no longer used since r38923nobu2018-08-161-2/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enumerator.c: fix for non-integral argument for ArithmeticSequence#lastmrkn2018-08-101-0/+3
| | | | | | | This fixes a bug of Enumerator::ArithmeticSequence#last in the case that a non-integral argument is passed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enumerator.c: undef new and allocate of ArithmeticSequencemrkn2018-08-091-0/+2
| | | | | | | | Undefine new and allocate methods of Enumerator::ArithmeticSequence. [ruby-core:82816] [Feature #13904] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enumerator.c: Introduce Enumerator::ArithmeticSequencemrkn2018-08-061-0/+412
| | | | | | | | | | | | | | | | | | | This commit introduces new core class Enumerator::ArithmeticSequence. Enumerator::ArithmeticSequence is a subclass of Enumerator, and represents a number generator of an arithmetic sequence. After this commit, Numeric#step and Range#step without blocks returned an ArithmeticSequence object instead of an Enumerator. This class introduces the following incompatibilities: - You can create a zero-step ArithmeticSequence, and its size is not ArgumentError, but Infinity. - You can create a negative-step ArithmeticSequence from a range. [ruby-core:82816] [Feature #13904] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enumerator.c: pretty kwagsnobu2018-03-151-1/+30
| | | | | | | * enumerator.c (append_method): pretty format for keyword arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Bug Fix Enumerator::Lazy#uniq state for multiple callnobu2018-03-131-7/+14
| | | | | | | | | | | | | | | | | | | | | | * enumerator.c (lazy_uniq_i): create new hash for each calls. [Fix GH-1820] Currently 2.5.0-preview1 :001 > arr = (0..100).lazy.uniq{|i| i % 10} => #<Enumerator::Lazy: #<Enumerator::Lazy: 0..100>:uniq> 2.5.0-preview1 :002 > arr.to_a => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 2.5.0-preview1 :003 > arr.to_a => [] Expected arr.to_a to always return same output From: Anmol Chopra <anmolchopra@rocketbox.in> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add a new #filter alias for #selecteregon2018-02-251-0/+1
| | | | | | | | | | | | | | | * In Enumerable, Enumerator::Lazy, Array, Hash and Set [Feature #13784] [ruby-core:82285] * Share specs for the various #select#select! methods and reuse them for #filter/#filter!. * Add corresponding filter tests for select tests. * Update NEWS. [Fix GH-1824] From: Alexander Patrick <adp90@case.edu> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby/ruby.h: remove unnecessary exports from C-APInormal2018-01-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Needlessly exporting can reduce performance locally and increase binary size. Increasing the footprint of our C-API larger is also detrimental to our development as it encourages tighter coupling with our internals; making it harder for us to preserve compatibility. If some parts of the core codebase needs access to globals, internal.h should be used instead of anything in include/ruby/*. "Urabe, Shyouhei" <shyouhei@ruby-lang.org> wrote: > On Thu, Jan 18, 2018 at 7:33 PM, Eric Wong <normalperson@yhbt.net> wrote: > > shyouhei@ruby-lang.org wrote: > >> https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61908 > >> > >> export rb_mFConst > > > > Why are we exporting all these and making the public C-API bigger? > > If anything, we should make these static. Thanks. > > No concrete reason, except they have already been externed in 2.5. > These variables had lacked declarations so far, which resulted in their > visibility to be that of extern. The commit is just confirming the status quo. > > I'm not against to turn them into static. This reverts changes from r61910, r61909, r61908, r61907, and r61906. * transcode.c (rb_eUndefinedConversionError): make static (rb_eInvalidByteSequenceError): ditto (rb_eConverterNotFoundError): ditto * process.c (rb_mProcGID, rb_mProcUid, rb_mProcID_Syscall): ditto * file.c (rb_mFConst): ditto * error.c (rb_mWarning, rb_cWarningBuffer): ditto * enumerator.c (rb_cLazy): ditto [Misc #14381] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* INFINITY is float. That of double is HUGE_VAL.shyouhei2018-01-191-1/+1
| | | | | | | | | | It seems HUGE_VAL is already used. Why not eliminate INTINITY. NAN is also float. That of double is called nan(). This is also fixed. Signed-off-by: Urabe, Shyouhei <shyouhei@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* use predefined ids in a few more placesnormal2018-01-091-7/+9
| | | | | | | | | | | | | | | Saves a little space on x86: text data bss dec hex filename 3684110 11968 34240 3730318 38eb8e ruby.before 3684086 11968 34240 3730294 38eb76 ruby.after * enumerator.c: include id.h, define aliases (Init_Enumeerator): remove unnecessary rb_intern calls * gc.c (should_be_callable): use idCall * vm.c (Init_VM): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Get rid of shadowing local variablesnobu2017-10-181-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enumerator.c: fix nested mapsnobu2017-06-101-0/+4
| | | | | | | | | | * enumerator.c (lazy_map_proc, lazy_grep_iter_proc): marks values returned by blocks are not packed in the case of nested maps, so that the result will be same as non-lazy version. based on the patch by akihikodaki (Akihiko Odaki) at [ruby-core:81638], without GCC extension. [Bug#13648] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Enumerator::Lazy#chunk_while defined.akr2016-11-051-0/+1
| | | | | | | | | | * enumerator.c (InitVM_Enumerator): Enumerator::Lazy#chunk_while defined. [Fix GH-1186] https://github.com/ruby/ruby/pull/1186 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enumerator.c: lazy enum improvementnobu2016-09-191-112/+382
| | | | | | | | | * enumerator.c (lazy_init_yielder): directly call stored functions. [Feature #6183] * enumerator.c (lazy_add_method): create lazy enumerator which uses lazy_init_yielder(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56185 b2dd03c8-39d4-4d8f-98ff-823fe69b080e