aboutsummaryrefslogtreecommitdiffstats
path: root/enum.c
Commit message (Collapse)AuthorAgeFilesLines
* RDoc: Enhanced introduction for Enumerable (#4004)Burdette Lamar2021-01-041-7/+129
| | | | | | | * RDoc: Enhanced introduction for Enumerable * RDoc: Enhanced introduction for Enumerable * RDoc: Enhanced introduction for Enumerable
* Fix indent [ci skip]Kazuhiro NISHIYAMA2021-01-051-4/+4
| | | | | Suggested by @hanachin at https://github.com/rurema/doctree/pull/2425#discussion_r551327592
* Add Enumerable#compact and Enumerator::Lazy#compactzverok2021-01-021-0/+43
|
* Removed leading spaces [ci skip]Nobuyoshi Nakada2020-12-161-1/+1
|
* Optimize `Enumerable#grep{_v}`Marc-Andre Lafortune2020-12-151-12/+40
| | | | [Bug #17030]
* Removed canonicalization for mathnNobuyoshi Nakada2020-11-101-10/+1
|
* Fix linksS-H-GAMELINKS2020-11-101-1/+1
|
* Don't redefine #rb_intern over and over againStefan Stüben2020-10-211-4/+1
|
* Respect visibility in non-array Enumerable#inject [Bug #13592]Nobuyoshi Nakada2020-07-241-1/+1
|
* add spaces [ci skip]卜部昌平2020-06-291-0/+14
|
* sum_iter: do not goto into a branch卜部昌平2020-06-291-107/+115
| | | | | I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
* Update example code in Enumerator#chunk documentation [ci skip]Jeremy Evans2020-06-121-1/+1
| | | | | | | | | 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]
* docs: fix typoszTheory2020-06-071-2/+2
|
* Fix max, min, minmax documentation (#3131)Masataka Pocke Kuwabara2020-05-261-3/+3
| | | | They only need that all objects implement <=>, but the documentation said it needs Comparable.
* Added more NORETURN declarationsNobuyoshi Nakada2020-05-111-0/+1
|
* decouple internal.h headers卜部昌平2019-12-261-4/+10
| | | | | | | | | | | | | | | | | | 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).
* [DOC] Improve documentation for Enumerable#tallyMarcus Stollsteimer2019-12-221-4/+4
|
* Added documentation for integer range sums (#1593)Eli Sadoff2019-12-111-0/+4
|
* Indicate `find_all` and `select` methods are aliases.Corey Farwell2019-12-111-0/+3
| | | This matches the documentation for `Enumerable::inject` and `Enumerable::reduce` which are also aliases.
* check interrupts at each frame pop timing.Koichi Sasada2019-11-291-3/+0
| | | | | | | | | | | | | | | | | | 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...
* Fix memory corruption in Enumerable#reverse_each [ruby-dev:50867] [Bug #16354]Kazuki Tsujimoto2019-11-191-3/+9
|
* Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans2019-11-181-4/+0
| | | | | | 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.
* rb_rescue / rb_rescue2 now free from ANYARGS卜部昌平2019-08-271-2/+4
| | | | | | 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.
* #define RB_BLOCK_CALL_FUNC_STRICT 1卜部昌平2019-08-271-2/+2
| | | | | | 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.
* Document that Enumerable#sum may not respect redefinition of Range#eachJeremy Evans2019-08-251-1/+1
| | | | | | | It already documented that it may not respect redefinition of Integer#+. Fixes [Bug #13700]
* Remove redundant each from `sum` example (#2190) [ci skip]OKURA Masafumi2019-08-171-1/+1
| | | | | It used to be `Enumerator#sum`, now it's range of string which calls `Enumerable#sum` and causes TypeError.
* enum.c: Remove unused #includeYusuke Endoh2019-08-071-1/+0
| | | | transient_heap.h is no longer needed.
* Predefine some IDsNobuyoshi Nakada2019-08-031-2/+1
|
* [DOC] Add link to Enumerable#grep from Enumerable#selectKazuhiro NISHIYAMA2019-07-091-1/+1
|
* squeeze space [ci skip]Kazuhiro NISHIYAMA2019-06-131-1/+1
|
* add comments to mention sort.reverse!Martin Dürst2019-06-131-0/+4
| | | | | | 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]
* Make size on an infinite each_slice enumerator return InfinityJeremy Evans2019-06-021-0/+5
| | | | Fixes [Bug #15889]
* enum.c (enum_tally): better example in rdocYusuke Endoh2019-05-231-2/+1
|
* Adding Enumerable#filter_mapAlfonso Jiménez2019-05-231-0/+41
| | | | | [Feature #15323] Closes: https://github.com/ruby/ruby/pull/2017
* [DOC] Use '&&' instead of 'and' in boolean expressionMarcus Stollsteimer2019-05-181-9/+9
|
* Improve doc for Enumerable#include? and member?okuramasafumi2019-05-131-4/+4
| | | | | | | | | | | | | 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: https://github.com/ruby/ruby/pull/2168
* memo.c might not always be initializedUrabe, Shyouhei2019-04-261-0/+4
| | | | | | | | | | | | | | | | | | | | 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
* [DOC] Add `ifnone` example to `find` documentation [ci skip]nagachika2019-04-121-4/+6
| | | | | | | | [Fix GH-2110] From: OKURA Masafumi <masafumi.o1988@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] fix markups [ci skip]nobu2019-03-221-26/+25
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enum.c: [DOC] tally does not take a blocknobu2019-02-081-1/+1
| | | | | | [Feature #11076] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * expand tabs.svn2019-02-071-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enum.c: Enumerable#tallynobu2019-02-071-0/+43
| | | | | | | * enum.c (enum_tally): new methods Enumerable#tally, which group and count elements of the collection. [Feature #11076] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enum.c: hosited out enum_hashifynobu2019-02-071-11/+11
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Prefer rb_check_arity when 0 or 1 argumentsnobu2018-12-061-10/+7
| | | | | | | 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
* Build error method name at failurenobu2018-12-051-6/+5
| | | | | | So `struct nmin_data` size is reduced. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Adjust indent [ci skip]nobu2018-12-051-9/+9
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Prefer rb_check_arity when 0 or 1 argumentsnobu2018-12-051-7/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* make `RARRAY_PTR_USE` more conservertive.ko12018-12-031-1/+0
| | | | | | | | | | | | | | | | | | | * 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://ci.ruby-lang.org/ruby/trunk@66165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* introduce TransientHeap. [Bug #14858]ko12018-10-301-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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://ci.ruby-lang.org/ruby/trunk@65449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * expand tabs.svn2018-10-301-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e