path: root/enum.c
AgeCommit message (Collapse)Author
2021-01-04RDoc: Enhanced introduction for Enumerable (#4004)Burdette Lamar
* RDoc: Enhanced introduction for Enumerable * RDoc: Enhanced introduction for Enumerable * RDoc: Enhanced introduction for Enumerable Notes: Merged-By: marcandre <>
2021-01-05Fix indent [ci skip]Kazuhiro NISHIYAMA
Suggested by @hanachin at
2021-01-02Add Enumerable#compact and Enumerator::Lazy#compactzverok
Notes: Merged:
2020-12-16Removed leading spaces [ci skip]Nobuyoshi Nakada
2020-12-15Optimize `Enumerable#grep{_v}`Marc-Andre Lafortune
[Bug #17030] Notes: Merged:
2020-11-10Removed canonicalization for mathnNobuyoshi Nakada
Notes: Merged:
2020-11-10Fix linksS-H-GAMELINKS
Notes: Merged:
2020-10-21Don't redefine #rb_intern over and over againStefan Stüben
Notes: Merged:
2020-07-24Respect visibility in non-array Enumerable#inject [Bug #13592]Nobuyoshi Nakada
2020-06-29add spaces [ci skip]卜部昌平
Notes: Merged:
2020-06-29sum_iter: do not goto into a branch卜部昌平
I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor. Notes: Merged:
2020-06-12Update example code in Enumerator#chunk documentation [ci skip]Jeremy Evans
The code assumed that /usr/share/dict/words did not use mixed case, and it does at least on a few operating systems. From CryptoRAT (Luke Elliot) Fixes [Bug #16957]
2020-06-07docs: fix typoszTheory
Notes: Merged:
2020-05-26Fix max, min, minmax documentation (#3131)Masataka Pocke Kuwabara
They only need that all objects implement <=>, but the documentation said it needs Comparable. Notes: Merged-By: k0kubun <>
2020-05-11Added more NORETURN declarationsNobuyoshi Nakada
2019-12-26decouple internal.h headers卜部昌平
Saves comitters' daily life by avoid #include-ing everything from internal.h to make each file do so instead. This would significantly speed up incremental builds. We take the following inclusion order in this changeset: 1. "ruby/config.h", where _GNU_SOURCE is defined (must be the very first thing among everything). 2. RUBY_EXTCONF_H if any. 3. Standard C headers, sorted alphabetically. 4. Other system headers, maybe guarded by #ifdef 5. Everything else, sorted alphabetically. Exceptions are those win32-related headers, which tend not be self- containing (headers have inclusion order dependencies). Notes: Merged:
2019-12-22[DOC] Improve documentation for Enumerable#tallyMarcus Stollsteimer
2019-12-11Added documentation for integer range sums (#1593)Eli Sadoff
2019-12-11Indicate `find_all` and `select` methods are aliases.Corey Farwell
This matches the documentation for `Enumerable::inject` and `Enumerable::reduce` which are also aliases.
2019-11-29check interrupts at each frame pop timing.Koichi Sasada
Asynchronous events such as signal trap, finalization timing, thread switching and so on are managed by "interrupt_flag". Ruby's threads check this flag periodically and if a thread does not check this flag, above events doesn't happen. This checking is CHECK_INTS() (related) macro and it is placed at some places (laeve instruction and so on). However, at the end of C methods, C blocks (IMEMO_IFUNC) etc there are no checking and it can introduce uninterruptible thread. To modify this situation, we decide to place CHECK_INTS() at vm_pop_frame(). It increases interrupt checking points. [Bug #16366] This patch can introduce unexpected events...
2019-11-19Fix memory corruption in Enumerable#reverse_each [ruby-dev:50867] [Bug #16354]Kazuki Tsujimoto
2019-11-18Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans
This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby. Notes: Merged:
2019-08-27rb_rescue / rb_rescue2 now free from ANYARGS卜部昌平
After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit deletes ANYARGS from rb_rescue / rb_rescue2, which revealed many arity / type mismatches.
2019-08-27#define RB_BLOCK_CALL_FUNC_STRICT 1卜部昌平
After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. Let's start from making rb_block_call_func_t strict, and apply RB_BLOCK_CALL_FUNC_ARGLIST liberally.
2019-08-25Document that Enumerable#sum may not respect redefinition of Range#eachJeremy Evans
It already documented that it may not respect redefinition of Integer#+. Fixes [Bug #13700]
2019-08-17Remove redundant each from `sum` example (#2190) [ci skip]OKURA Masafumi
It used to be `Enumerator#sum`, now it's range of string which calls `Enumerable#sum` and causes TypeError.
2019-08-07enum.c: Remove unused #includeYusuke Endoh
transient_heap.h is no longer needed.
2019-08-03Predefine some IDsNobuyoshi Nakada
2019-07-09[DOC] Add link to Enumerable#grep from Enumerable#selectKazuhiro NISHIYAMA
2019-06-13squeeze space [ci skip]Kazuhiro NISHIYAMA
2019-06-13add comments to mention sort.reverse!Martin Dürst
For array.c (Array#sort) and enum.c (Enumerable#sort_by), add comments mentioning that sort.reverse! / sort_by { ... }.reverse! can/should be used to reverse the result. [ci skip]
2019-06-02Make size on an infinite each_slice enumerator return InfinityJeremy Evans
Fixes [Bug #15889]
2019-05-23enum.c (enum_tally): better example in rdocYusuke Endoh
2019-05-23Adding Enumerable#filter_mapAlfonso Jiménez
[Feature #15323] Closes:
2019-05-18[DOC] Use '&&' instead of 'and' in boolean expressionMarcus Stollsteimer
2019-05-13Improve doc for Enumerable#include? and member?okuramasafumi
Existing doc for Enumerable#include? and member? has some problems. * `IO.constants` is not commonly used, and only some know that `SEEK_SET` is actually included in constants. * `IO.constants` is actually an Array, not the example is not appropriate for `Enumerable` module. So in this commit, the old example is replaced with new one. New example uses integer range, which is much simpler and easier to understand. Closes:
2019-04-26memo.c might not always be initializedUrabe, Shyouhei
memo.float_value might change inside of hash_sum. In case it flipped from false to true there, and the calculated sum is Inf, memo.c might not be initialized at all. This is bad. Found using memory sanitizer: ==55293==WARNING: MemorySanitizer: use-of-uninitialized-value #0 0x55dfb8d6c529 in rb_float_new_inline internal.h:1814:53 #1 0x55dfb8d1b30c in enum_sum enum.c:4017:18 #2 0x55dfb86d75ad in call_cfunc_m1 vm_insnhelper.c:2041:12 #3 0x55dfb864b141 in vm_call_cfunc_with_frame vm_insnhelper.c:2207:11 #4 0x55dfb85e843d in vm_call_cfunc vm_insnhelper.c:2225:12 #5 0x55dfb85e08f3 in vm_call_method_each_type vm_insnhelper.c:2560:9 #6 0x55dfb85de9c7 in vm_call_method vm_insnhelper.c:2686:13 #7 0x55dfb849eac6 in vm_call_general vm_insnhelper.c:2730:12 #8 0x55dfb8686103 in vm_sendish vm_insnhelper.c:3623:11 #9 0x55dfb84dc29e in vm_exec_core insns.def:789:11
2019-04-12[DOC] Add `ifnone` example to `find` documentation [ci skip]nagachika
[Fix GH-2110] From: OKURA Masafumi <> git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-22[DOC] fix markups [ci skip]nobu
git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-08enum.c: [DOC] tally does not take a blocknobu
[Feature #11076] git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-07* expand tabs.svn
git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-07enum.c: Enumerable#tallynobu
* enum.c (enum_tally): new methods Enumerable#tally, which group and count elements of the collection. [Feature #11076] git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-07enum.c: hosited out enum_hashifynobu
git-svn-id: svn+ssh:// 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:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-05Build error method name at failurenobu
So `struct nmin_data` size is reduced. git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-05Adjust indent [ci skip]nobu
git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-05Prefer rb_check_arity when 0 or 1 argumentsnobu
git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-03make `RARRAY_PTR_USE` more conservertive.ko1
* include/ruby/ruby.h: de-transient at `RARRAY_PTR_USE` and `RARRAY_PTR_USE_START`. Introduce `RARRAY_PTR_USE_TRANSIENT` and `RARRAY_PTR_USE_START_TRANSIENT` if you don't want to de-transient an array. Generally, it is difficult so C-extension writers should not use them. * array.c: use `RARRAY_PTR_USE_TRANSIENT` if possible. * hash.c: ditto. * enum.c (enum_sort_by): remove `rb_ary_transient_heap_evacuate()` because `RARRAY_PTR_USE` do de-transient. git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-30introduce TransientHeap. [Bug #14858]ko1
* transient_heap.c, transient_heap.h: implement TransientHeap (theap). theap is designed for Ruby's object system. theap is like Eden heap on generational GC terminology. theap allocation is very fast because it only needs to bump up pointer and deallocation is also fast because we don't do anything. However we need to evacuate (Copy GC terminology) if theap memory is long-lived. Evacuation logic is needed for each type. See [Bug #14858] for details. * array.c: Now, theap for T_ARRAY is supported. ary_heap_alloc() tries to allocate memory area from theap. If this trial sccesses, this array has theap ptr and RARRAY_TRANSIENT_FLAG is turned on. We don't need to free theap ptr. * ruby.h: RARRAY_CONST_PTR() returns malloc'ed memory area. It menas that if ary is allocated at theap, force evacuation to malloc'ed memory. It makes programs slow, but very compatible with current code because theap memory can be evacuated (theap memory will be recycled). If you want to get transient heap ptr, use RARRAY_CONST_PTR_TRANSIENT() instead of RARRAY_CONST_PTR(). If you can't understand when evacuation will occur, use RARRAY_CONST_PTR(). (re-commit of r65444) git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-30* expand tabs.svn
git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e