summaryrefslogtreecommitdiff
path: root/enumerator.c
AgeCommit message (Collapse)Author
2018-12-12enumerator.c: Add rb_arithmetic_sequence_components_tmrkn
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
2018-12-12enumerator.c: rb_arithmetic_sequence_extractmrkn
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
2018-12-06Prefer rb_check_arity when 0 or 1 argumentsnobu
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
2018-12-03use RARRAY_AREF instead of RARRAY_PTR_USE.ko1
* 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
2018-11-27Add Float::INFINITY or nil to call-seq of Enumerator::Chain#size [ci skip]kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-27enumerator.c (enum_chain_yield_block): use predefined IDnormal
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
2018-11-24Implement Enumerator#+ and Enumerable#chain [Feature #15144]knu
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
2018-11-16avoid division by zeroshyouhei
* 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
2018-10-22* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-22Set the size of a new enumerator created by Enumerator#each with arguments ↵knu
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
2018-10-12enumerator.c: [DOC] small fixstomar
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-18Lazy Enumerator reduce intermediate array creationnobu
[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
2018-09-12[DOC] aseq.each always return self [ci skip]kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-12[DOC] Add the documentation of ArithmeticSequencemrkn
[ci-skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-12enumerator.c: Fix ArithmeticSequence for complex stepmrkn
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
2018-09-12Revert "enumerator.c: Fix ArithmeticSequence for complex step"mrkn
This reverts commit 0a0f8238d02a2dfff4cd2892408e14cb826cec7e. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-12enumerator.c: Fix ArithmeticSequence for complex stepmrkn
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
2018-09-05enumerator.c: [DOC] Enumerator::Lazy#force [ci skip]nobu
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
2018-08-20Remove extra semicolonkazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-16Adding Enumerator::Lazy#uniq and Enumerator::Lazy#grep_v to proc chainingnobu
[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
2018-08-16enumerator.c: id_lazy is no longer used since r38923nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-10enumerator.c: fix for non-integral argument for ArithmeticSequence#lastmrkn
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
2018-08-09enumerator.c: undef new and allocate of ArithmeticSequencemrkn
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
2018-08-06enumerator.c: Introduce Enumerator::ArithmeticSequencemrkn
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
2018-03-15enumerator.c: pretty kwagsnobu
* 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
2018-03-13Bug Fix Enumerator::Lazy#uniq state for multiple callnobu
* 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
2018-02-25Add a new #filter alias for #selecteregon
* 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
2018-01-24ruby/ruby.h: remove unnecessary exports from C-APInormal
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
2018-01-19INFINITY is float. That of double is HUGE_VAL.shyouhei
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
2018-01-09use predefined ids in a few more placesnormal
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
2017-10-18Get rid of shadowing local variablesnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-10enumerator.c: fix nested mapsnobu
* 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
2016-11-05Enumerator::Lazy#chunk_while defined.akr
* 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
2016-09-19enumerator.c: lazy enum improvementnobu
* 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
2016-07-29rb_funcallvnobu
* *.c: rename rb_funcall2 to rb_funcallv, except for extensions which are/will be/may be gems. [Fix GH-1406] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-20enumerator.c: Enumerator::Lazy#uniqnobu
* enumerator.c (lazy_uniq): new method Enumerator::Lazy#uniq. [Feature #11090] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-15enumerator.c: use ALLOCVnobu
* enumerator.c (lazy_init_iterator): use ALLOCV instead of tmp array. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-09* *.c (*_memsize): do not check ptr.ko1
NULL checking is finished Before call of memsize functions. See r52979. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08enumerator.c: lazy_grep_vnobu
* enumerator.c (lazy_grep_v): add Enumerator::Lazy#grep_v as well as Enumerable, to enumerate lazily. [ruby-core:71845] [Feature #11773] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-28preserve encodings in error messagesnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-11* internal.h: use T_IMEMO to represent `struct MEMO' value.ko1
memo->v1 and memo->v2 is WB protected values. So use MEMO_V1/V2_SET() macros to set these values. memo->u3 is ambiguous (sometimes a VALUE, sometimes an integer value), so use gc_mark_maybe() in gc.c to mark it. Rename NEW_MEMO() to MEMO_NEW(). Move MEMO_FOR and NEW_MEMO_FOF macros from node.h. Export a rb_imemo_new() function for ext/ripper. * node.h: remove NODE_MEMO. * enum.c: catch up these change. * enumerator.c: ditto. * load.c: ditto. * ext/objspace/objspace.c (count_nodes): ditto. * gc.c (gc_mark_children): mark imemo_memo type. * parse.y (new_args_gen): use T_IMEMO. (I'm not sure it is working correctly...) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-11* internal.h: define struct MEMO.ko1
* enum.c: use MEMO. * enumerator.c: ditto. * load.c: ditto. * node.h: return (struct MEMO *) pointer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-01use 0 for reservednobu
use 0 for rb_data_type_t::reserved instead of NULL, since its type may be changed in the future and possibly not a pointer type. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15* internal.h: Include ruby.h and ruby/encoding.h to beakr
includable without prior inclusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-20* enum.c (enum_slice_when): New method: Enumerable#slice_when.akr
(slicewhen_i): New function. (slicewhen_ii): New function. * enumerator.c (InitVM_Enumerator): New method: Enumerator::Lazy#slice_when. [ruby-core:62499] [Feature #9826] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-28symbols instead of IDsnobu
* encoding.c (rb_enc_get_index): deal with symbols instead of IDs to get rid of inadvertent pin-downs. * enum.c (chunk_ii): ditto. * enumerator.c (append_method): ditto. * iseq.c (iseq_load): ditto. * marshal.c (w_symbol, r_symlink, r_symreal, r_symbol): ditto. * signal.c (trap_handler): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-03Init functions don't need ID cachesnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-18constify parametersnobu
* include/ruby/intern.h: constify `argv` parameters. * include/ruby/ruby.h: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-25* enumerator.c: [DOC] Fix example to show Enumerator#peek behaviorzzak
Patch by Erik Hollembeak [Bug #9814] [ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-24enumerator.c: adjust style [ci skip]nobu
* enumerator.c (yielder_yield_push): Insert a break after the method return value. [fix GH-617] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e