* enum.c (enum_inject): return nil if no iteration, instead of
Qundef.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(struct nmin_data): New field to record the n-th maximumelement, limit
(nmin_filter): Update limit field.
(nmin_i): Drop too big eleents.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47923 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
descending order.
[ruby-core:65452] Suggested by David Grayson.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enum.c (enum_any): optimize object allocations for Array and
Hash when `each` is not redefined, always false if empty and the
case without a block. [fix GH-617]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enum.c (enum_each_slice, enum_each_cons): make more efficient by
allocating less and recycling block argument arrays if possible.
[Fixes GH-596]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enum.c (find_i): yield multiple values instead of a packed
array, so that lambda block can work. with tests by Alex
Rothenberg. [ruby-core:61340] [Bug #9605]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45286 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
optional argument.
(nmin_cmp): New function.
(nmin_block_cmp): Ditto
(nmin_filter): Ditto.
(nmin_i): Ditto.
(nmin_run): Ditto.
(enum_min): Call nmin_run if the optional argument is given.
(nmin_max): Ditto.
(nmin_min_by): Ditto.
(nmin_max_by): Ditto.
* range.c: Range#{min,max} extended to take an optional argument.
(range_min): Call range_first if the optional argument is given.
(range_max): Call rb_call_super if the optional argument is given.
[ruby-core:57111] [Feature #8887]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (RB_BLOCK_CALL_FUNC_ARGLIST): for declaration
argument list of rb_block_call_func.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
there are not new relations.
* enum.c (enum_sort_by): ditto.
* struct.c (setup_struct): use RARRAY_RAWPTR().
* vm_eval.c (yield_under): ditto.
* ext/pathname/pathname.c (path_entries): use RARRAY_AREF().
* ext/pathname/pathname.c (path_s_glob): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
RBASIC_CLASS(obj) macro which returns a class of `obj'.
This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
This function reveal interal (hidden) object by rb_obj_hide().
Note that do not change class before and after hiding.
Only permitted example is:
klass = RBASIC_CLASS(obj);
rb_obj_hide(obj);
....
rb_obj_reveal(obj, klass);
TODO: API design. rb_obj_reveal() should be replaced with others.
TODO: modify constified variables using cast may be harmful for
compiler's analysis and optimizaton.
Any idea to prohibt inserting RBasic::klass directly?
If rename RBasic::klass and force to use RBASIC_CLASS(obj),
then all codes such as `RBASIC(obj)->klass' will be
compilation error. Is it acceptable? (We have similar
experience at Ruby 1.9,
for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Patch by Dan Bernier and Rich Bruchal of newhaven.rb
[Github documenting-ruby/ruby#8]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This makes Lazy#cycle no longer needed, so it was removed.
Make Enumerator#chunk and slice_before return lazy Enumerators.
[Bug #7715]
* internal.h: Remove ref to rb_enum_cycle_size; no longer needed
* enum.c: Make enum_cycle_size static.
* test/ruby/test_lazy_enumerator.rb: Test for above
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e