Граф коммитов

440 Коммитов

Автор SHA1 Сообщение Дата
Burdette Lamar 046f1bf492
Enhanced RDoc for Enumerable#inject (#4876) 2021-09-20 18:19:21 -05:00
S-H-GAMELINKS 032534dbdf Using RB_BIGNUM_TYPE_P macro 2021-09-11 09:13:24 +09:00
Burdette Lamar 967b9743fa
Enhanced RDoc for Enumerable (#4808)
#to_a
    #to_h
    #inject
2021-09-10 17:21:21 -05:00
Nobuyoshi Nakada 03e7fc895e Extracted repeatedly defined IDs 2021-07-27 15:40:27 +09:00
Burdette Lamar d2d443efc1
Enhanced RDoc for Enumerable (#4479)
Methods treated:

    #count
    #find
    #find_index
    #select
    #filter_map
    #reject
    #map
    #flat_map
2021-05-10 14:00:36 -05:00
Burdette Lamar 43380401fa
Enhanced RDoc for Enumerable (#4473)
Enhanced RDoc for Enumerable: #grep and #grep_v.
2021-05-08 14:50:15 -05:00
Kenichi Kamiya aceb8c0b4b
Fix Enumerable#tally with some arguments pattern [Feature #17744]
* Add test cases for Enumerable#tally with hash argument

* Add ruby/spec for Enumerable#tally with hash argument

* Fix Enumerable#tally does not update given frozen hash

* Add test cases for Enumerable#tally with hash convertible arguments

* Fix SEGV when Enumerable#tally takes non Hash convertible

* FIx cosmetic damage enum.c
2021-03-27 12:55:46 +09:00
Nobuyoshi Nakada 9143d21b1b
Enumerable#tally with the resulting hash [Feature #17744] 2021-03-26 16:29:21 +09:00
Nobuyoshi Nakada cfadbf2fc4
Add write-barrier in tally 2021-03-20 23:53:57 +09:00
Marc-Andre Lafortune a85ed626f1 Fix Enumerable#inject with high negative fixnums [Bug #17731] 2021-03-19 00:21:41 -04:00
Nobuyoshi Nakada 382d3a4516
Improve Enumerable#tally performance
Iteration per second (i/s)

|       |compare-ruby|built-ruby|
|:------|-----------:|---------:|
|tally  |      52.814|   114.936|
|       |           -|     2.18x|
2021-03-16 23:06:41 +09:00
Burdette Lamar f2d0d4cb0a
RDoc: Enhanced introduction for Enumerable (#4004)
* RDoc: Enhanced introduction for Enumerable

* RDoc: Enhanced introduction for Enumerable

* RDoc: Enhanced introduction for Enumerable
2021-01-04 23:39:13 -05:00
Kazuhiro NISHIYAMA 3fee9e7021
Fix indent [ci skip]
Suggested by @hanachin at
https://github.com/rurema/doctree/pull/2425#discussion_r551327592
2021-01-05 00:19:48 +09:00
zverok b8d33df1d9 Add Enumerable#compact and Enumerator::Lazy#compact 2021-01-02 17:27:24 +09:00
Nobuyoshi Nakada b30d7fea56
Removed leading spaces [ci skip] 2020-12-16 12:14:30 +09:00
Marc-Andre Lafortune d5f0d338c7 Optimize `Enumerable#grep{_v}`
[Bug #17030]
2020-12-15 12:54:45 -05:00
Nobuyoshi Nakada b958e2add8 Removed canonicalization for mathn 2020-11-10 11:14:15 +09:00
S-H-GAMELINKS 8b3653b484 Fix links 2020-11-10 11:04:00 +09:00
Stefan Stüben 8c2e5bbf58 Don't redefine #rb_intern over and over again 2020-10-21 12:45:18 +09:00
Nobuyoshi Nakada 3ead2770a1
Respect visibility in non-array Enumerable#inject [Bug #13592] 2020-07-24 21:08:50 +09:00
卜部昌平 c47b805d8c add spaces [ci skip] 2020-06-29 11:05:41 +09:00
卜部昌平 d060ebf83c sum_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.
2020-06-29 11:05:41 +09:00
Jeremy Evans b212c7c7d1 Update example code in Enumerator#chunk documentation [ci skip]
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-12 09:11:43 -07:00
szTheory fa37a220f6 docs: fix typo 2020-06-07 10:32:33 +09:00
Masataka Pocke Kuwabara a3f498e44c
Fix max, min, minmax documentation (#3131)
They only need that all objects implement <=>,
but the documentation said it needs Comparable.
2020-05-26 23:48:46 -07:00
Nobuyoshi Nakada 5d430c1b34
Added more NORETURN declarations 2020-05-11 00:40:14 +09:00
卜部昌平 5e22f873ed decouple 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).
2019-12-26 20:45:12 +09:00
Marcus Stollsteimer bb05cdcd78 [DOC] Improve documentation for Enumerable#tally 2019-12-22 22:36:14 +01:00
Eli Sadoff 7e9b1609da Added documentation for integer range sums (#1593) 2019-12-11 11:25:54 +09:00
Corey Farwell 69aa927a40 Indicate `find_all` and `select` methods are aliases.
This matches the documentation for `Enumerable::inject` and `Enumerable::reduce` which are also aliases.
2019-12-11 11:15:12 +09:00
Koichi Sasada 36da0b3da1 check interrupts at each frame pop timing.
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-29 17:47:02 +09:00
Kazuki Tsujimoto ff41663403
Fix memory corruption in Enumerable#reverse_each [ruby-dev:50867] [Bug #16354] 2019-11-19 15:35:14 -06:00
Jeremy Evans ffd0820ab3 Deprecate taint/trust and related methods, and make the methods no-ops
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.
2019-11-18 01:00:25 +02:00
卜部昌平 5c7c2d9951 rb_rescue / rb_rescue2 now free from ANYARGS
After 5e86b005c0, 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 15:52:26 +09:00
卜部昌平 7329b3339a #define RB_BLOCK_CALL_FUNC_STRICT 1
After 5e86b005c0, 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-27 15:52:26 +09:00
Jeremy Evans e496e96547 Document that Enumerable#sum may not respect redefinition of Range#each
It already documented that it may not respect redefinition
of Integer#+.

Fixes [Bug #13700]
2019-08-25 12:50:19 -07:00
OKURA Masafumi efd37f8fc3 Remove redundant each from `sum` example (#2190) [ci skip]
It used to be `Enumerator#sum`, now it's range of string which calls
`Enumerable#sum` and causes TypeError.
2019-08-17 08:52:23 +09:00
Yusuke Endoh 58dec9625c enum.c: Remove unused #include
transient_heap.h is no longer needed.
2019-08-07 22:24:20 +09:00
Nobuyoshi Nakada 4ea5c5610a
Predefine some IDs 2019-08-03 10:18:39 +09:00
Kazuhiro NISHIYAMA 515e106fb7
[DOC] Add link to Enumerable#grep from Enumerable#select 2019-07-09 13:01:11 +09:00
Kazuhiro NISHIYAMA 69509df2f4
squeeze space [ci skip] 2019-06-13 16:42:31 +09:00
Martin Dürst 7f79a86d8b add comments to mention sort.reverse!
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-13 15:30:03 +09:00
Jeremy Evans 17af8bfce6 Make size on an infinite each_slice enumerator return Infinity
Fixes [Bug #15889]
2019-06-02 20:00:35 -07:00
Yusuke Endoh c04ef141d2 enum.c (enum_tally): better example in rdoc 2019-05-23 23:35:26 +09:00
Alfonso Jiménez 0acbdd1ed0
Adding Enumerable#filter_map
[Feature #15323]
Closes: https://github.com/ruby/ruby/pull/2017
2019-05-23 14:39:16 +09:00
Marcus Stollsteimer f782e5bdcf [DOC] Use '&&' instead of 'and' in boolean expression 2019-05-18 13:05:26 +02:00
okuramasafumi 559cad9f2d Improve doc for Enumerable#include? and member?
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
2019-05-13 00:43:05 +09:00
Urabe, Shyouhei 40b5f2b85d memo.c might not always be initialized
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-26 15:59:40 +09:00
nagachika 39b04bc698 [DOC] Add `ifnone` example to `find` documentation [ci skip]
[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
2019-04-12 14:32:31 +00:00
nobu 56557ec28a [DOC] fix markups [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-22 11:04:59 +00:00