Koichi Sasada
a24eeee556
Use `Primitive.mandatory_only?` for `Array#sample`
2021-11-15 15:58:56 +09:00
Peter Zhu
aeae6e2842
[Feature #18290 ] Remove all usages of rb_gc_force_recycle
...
This commit removes usages of rb_gc_force_recycle since it is a burden
to maintain and makes changes to the GC difficult.
2021-11-08 14:05:54 -05:00
180909
724c657700
Remove repeated 'the' ( #4966 )
2021-10-13 23:05:44 -07:00
S.H
dc9112cf10
Using NIL_P macro instead of `== Qnil`
2021-10-03 22:34:45 +09:00
Nobuyoshi Nakada
a27c274f04
[DOC] Fix broken links [ci skip]
...
* As the "doc/" prefix is specified by the `--page-dir` option,
remove from the rdoc references.
* Refer to the original .rdoc instead of the converted .html.
2021-09-15 14:16:14 +09:00
Burdette Lamar
1af5a0c574
Bsearch doc for Array and Range ( #4838 )
...
This PR creates doc/bsearch.rdoc to provide common documentation for bsearch in Array and Range.
2021-09-14 16:08:21 -05:00
S-H-GAMELINKS
032534dbdf
Using RB_BIGNUM_TYPE_P macro
2021-09-11 09:13:24 +09:00
卜部昌平
ce54282b75
include/ruby/internal/intern/array.h: add doxygen
...
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
Aaron Patterson
cd4f5b1322
Guard array when appending
...
This prevents early collection of the array. The GC doesn't see the
array on the stack when Ruby is compiled with optimizations enabled
[ruby-core:105099] [Bug #18140 ]
2021-09-02 01:22:19 +09:00
universato
b6691e9737
Fix a code in the Array#min documentation.
2021-08-31 20:56:52 +09:00
Mike Dalessio
d43279edac
Fix length calculation for Array#slice!
...
Commit 4f24255
introduced a bug which allows a length to be passed to
rb_ary_new4 which is too large, resulting in invalid memory access.
For example:
(1..1000).to_a.slice!(-2, 1000)
2021-08-29 09:41:22 +09:00
S.H
378e8cdad6
Using RBOOL macro
2021-08-02 12:06:44 +09:00
Koichi Sasada
fa0279d947
should not share same `def` for specialized method
...
Because the key of redefine table is `def`, `def` should be
unique for each optimized method (`alias` is not allowed).
2021-07-29 00:56:48 +09:00
Burdette Lamar
c1741df1a1
What's Here for Numeric and Comparable
2021-06-21 10:38:16 -07:00
Nobuyoshi Nakada
e4f891ce8d
Adjust styles [ci skip]
...
* --braces-after-func-def-line
* --dont-cuddle-else
* --procnames-start-lines
* --space-after-for
* --space-after-if
* --space-after-while
2021-06-17 10:13:40 +09:00
Jeremy Evans
8b00bfb7c2
Do not allow array modifications after freeze inside sort!
...
If freezing an array inside sort!, previously the array could be
modified after the freeze. This checks whether the receiver is
frozen after every yield and potential call to #> or #<,
preventing modifications if the receiver is frozen inside the
block or by the #> or #< call.
Fixes [Bug #17739 ]
2021-05-21 18:33:56 -07:00
Masataka Pocke Kuwabara
e3e5596782
Fix example code in Array#max doc
...
`[0, 1, 2, 3].max(6)` actually returns `[3, 2, 1, 0]`, but the doc said
it returns `[3, 2, 1]`.
2021-05-08 09:41:08 -04:00
Peter Zhu
3ca291c9ae
Correctly update array capacity after realloc
...
Reallocating to a smaller size in the transient heap may result in no
change in the actual capacity but the capacity of the array is still
updated to the smaller value.
This commit changes `ary_heap_realloc` to return the new capacity which
can be used by the caller to correctly update the capacity.
2021-05-04 11:46:23 -04:00
Yusuke Endoh
fb04c69418
array.c (rb_ary_zip): take only as many as needed from an Enumerator ( #4389 )
...
[Bug #17814 ]
2021-04-21 13:02:29 +09:00
Travis Hunter
55d91a096a
Add Array#intersect?
2021-04-16 16:06:36 +09:00
Nobuyoshi Nakada
f46bbb2e99
[DOC] Improve an example of Array#count comparison [ci skip]
2021-03-29 11:35:38 +09:00
Kenichi Kamiya
813c3333a9
[Doc] Fix Array#count comparing strategy
2021-03-28 14:17:52 -04:00
Nobuyoshi Nakada
e019dd24df
Ensure the receiver is modifiable before shrinking [Bug #17736 ]
...
* Ensure the receiver is modifiable before shinking [Bug #17736 ]
* Assert the receivers are not modified
2021-03-20 19:15:38 +09:00
Nobuyoshi Nakada
e8b210542b
Define rb_to_array which converts with to_a
2021-02-12 12:15:57 +09:00
Nobuyoshi Nakada
947d93b715
[DOC] {Array,MatchData}#values_at understand ranges [ci skip]
2021-02-07 10:30:43 +09:00
Masaki Matsushita
e1e61e256b
Improve performance of Array#- when it is called with empty array
...
This change make Array#- return a copy of the receiver when
the other array is empty.
2021-02-06 17:23:16 +09:00
Nobuyoshi Nakada
94fb62e4a0
[DOC] Fixed a markup in Array#sum [ci skip]
2021-02-06 13:40:50 +09:00
BurdetteLamar
383685b52b
Explicit references to Enumerable
2021-01-20 09:33:41 -08:00
Marc-Andre Lafortune
fad9922d84
Revert "[Document][Array] Add missing call-seq for Array#append"
...
This reverts commit ac1a4bccbd
.
See https://github.com/ruby/ruby/pull/4088
2021-01-18 11:05:05 -05:00
Juanito Fatas
ac1a4bccbd
[Document][Array] Add missing call-seq for Array#append
2021-01-18 09:39:30 -05:00
Burdette Lamar
a2941d7134
Add What's Here to Array RDoc ( #4062 )
...
* Add What's Here to Array RDoc
2021-01-15 12:08:01 -06:00
Victor Shepelev
5253b9579a
Document usage of ArithmeticSequence in Array#slice, and add to NEWS ( #3952 )
2020-12-21 09:32:30 +09:00
Jeremy Evans
05313c914b
Use category: :deprecated in warnings that are related to deprecation
...
Also document that both :deprecated and :experimental are supported
:category option values.
The locations where warnings were marked as deprecation warnings
was previously reviewed by shyouhei.
Comment a couple locations where deprecation warnings should probably
be used but are not currently used because deprecation warning
enablement has not occurred at the time they are called
(RUBY_FREE_MIN, RUBY_HEAP_MIN_SLOTS, -K).
Add assert_deprecated_warn to test assertions. Use this to simplify
some tests, and fix failing tests after marking some warnings with
deprecated category.
2020-12-18 09:54:11 -08:00
Koichi Sasada
344ec26a99
tuning trial: newobj with current ec
...
Passing current ec can improve performance of newobj. This patch
tries it for Array and String literals ([] and '').
2020-12-07 08:28:36 +09:00
Koichi Sasada
8247b8edde
should not use rb_ary_modify()
...
ractor_copy() used rb_ary_modify() to make sure this array is not
sharing anything, but it also checks frozen flag. So frozen arrays
raises an error. To solve this issue, this patch introduces new
function rb_ary_cancel_sharing() which makes sure the array does not
share another array and it doesn't check frozen flag.
[Bug #17343 ]
A test is quoted from https://github.com/ruby/ruby/pull/3817
2020-12-01 13:18:32 +09: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
Jeremy Evans
2a294d499b
Make Array methods return Array instances instead of subclass instances
...
This changes the following methods to return Array instances instead
of subclass instances:
* Array#drop
* Array#drop_while
* Array#flatten
* Array#slice!
* Array#slice/#[]
* Array#take
* Array#take_while
* Array#uniq
* Array#*
Fixes [Bug #6087 ]
2020-11-03 14:01:38 -08:00
Stefan Stüben
8c2e5bbf58
Don't redefine #rb_intern over and over again
2020-10-21 12:45:18 +09:00
Kenta Murata
a6a8576e87
Feature #16812 : Allow slicing arrays with ArithmeticSequence ( #3241 )
...
* Support ArithmeticSequence in Array#slice
* Extract rb_range_component_beg_len
* Use rb_range_values to check Range object
* Fix ary_make_partial_step
* Fix for negative step cases
* range.c: Describe the role of err argument in rb_range_component_beg_len
* Raise a RangeError when an arithmetic sequence refers the outside of an array
[Feature #16812 ]
2020-10-21 02:40:18 +09:00
Burdette Lamar
54fb8fb62a
Comply with guide for method doc: array.c ( #3506 )
...
Methods:
any?
all?
one?
none?
sum
shuffle!
shuffle
sample
2020-09-02 14:02:34 -05:00
Burdette Lamar
94430d009a
Comply with guide for method doc: array.c ( #3499 )
...
Methods considered:
count
flatten!
flatten
cycle
permutation
combination
repeated_permutation
repeated_combination
product
take
take_while
drop
drop_while
2020-09-01 12:49:48 -05:00
Burdette Lamar
50736f127a
Comply with guide for method doc: array.c ( #3489 )
...
Methods considered:
&
intersection
|
union
max
min
minmax
uniq!
uniq
compact!
compact
2020-08-31 16:25:11 -05:00
Burdette Lamar
e744d4070c
Comply with guide for method doc: array.c ( #3484 )
...
Methods:
+
concat
*
assoc
rassoc
==
eql?
hash
include?
<=>
-
difference
2020-08-31 14:53:54 -05:00
Burdette Lamar
1f4c507afb
Comply with guide for method doc: array.c ( #3477 )
...
Methods considered:
delete_at
slice!
reject!
reject
delete_if
zip
transpose
replace
clear
fill
2020-08-31 13:16:10 -05:00
Burdette Lamar
585a659b1e
Comply with guide for method doc: array.c ( #3475 )
...
Methods considered:
bsearch
bsearch_index
sort_by!
collect
collect!
values_at
select
select!
keep_if
delete
2020-08-30 10:34:13 -05:00
Burdette Lamar
726f2e59f9
Comply with guide for method doc: array.c ( #3474 )
...
Methods considered:
length
empty?
join
inspect
to_a
to_h
to_ary
reverse!
reverse
rotate!
rotate
sort!
sort
2020-08-29 15:16:02 -05:00
Burdette Lamar
f0ad5594bf
Comply with guide for method doc: array.c ( #3473 )
...
Methods considered:
at
first
last
fetch
index
rindex
[]
insert
each
each_index
reverse_each
2020-08-29 12:15:06 -05:00
Burdette Lamar
45c40f5631
Comply with guide for method doc: array.c ( #3469 )
...
Methods:
- freeze
- try_convert
- new
- \<<
- push
- pop
- shift
- unshift
- []
2020-08-28 14:56:02 -05:00
Burdette Lamar
1d3e87a28c
Remove checks for self returned in array.c and hash.c examples ( #3446 )
...
Further compliance with https://github.com/ruby/ruby/blob/master/doc/method_documentation.rdoc#details-and-examples-
2020-08-23 12:10:01 -05:00