summaryrefslogtreecommitdiff
path: root/array.c
Commit message (Collapse)AuthorAgeFilesLines
* Add comment in array.c about flagsPeter Zhu2022-07-211-0/+31
|
* Add RARRAY_SHARED_FLAGPeter Zhu2022-07-211-3/+3
|
* Refactor macros of array.cPeter Zhu2022-07-211-35/+7
| | | | | Move some macros in array.c to internal/array.h so that other files can also access these macros.
* Add RARRAY_LITERAL_FLAG for array literalsPeter Zhu2022-07-201-12/+34
| | | | | | | | | | | | | Array created as literals during iseq compilation don't need a reference count since they can never be modified. The previous implementation would mutate the hidden array's reference count, causing copy-on-write invalidation. This commit adds a RARRAY_LITERAL_FLAG for arrays created through rb_ary_literal_new. Arrays created with this flag do not have reference count stored and just assume they have infinite number of references. Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
* Remove unused variable in array.cPeter Zhu2022-07-181-12/+11
| | | | vshared is no longer used.
* [Feature #18901] Support size pool movement for ArraysMatt Valentine-House2022-07-121-1/+41
| | | | | | | | | | | | | This commit enables Arrays to move between size pools during compaction. This can occur if the array is mutated such that it would fit in a different size pool when embedded. The move is carried out in two stages: 1. The RVALUE is moved to a destination heap during object movement phase of compaction 2. The array data is re-embedded and the original buffer free'd if required. This happens during the update references step
* Add missing write barriers to Array#replaceAlan Wu2022-04-281-2/+4
| | | | | | | Previously it made object references without using write barriers, creating GC inconsistencies. See: http://ci.rvm.jp/results/trunk-gc-asserts@phosphorus-docker/3925529
* Correct whitespace in array.c (#5791)Burdette Lamar2022-04-111-10/+370
|
* [DOC] Enhanced RDoc for Array intro (#5781)Burdette Lamar2022-04-101-44/+90
| | | This covers the first few sections of the class doc for Array.
* [DOC] Use simple references to operator methodsNobuyoshi Nakada2022-03-261-5/+5
| | | | | | | Method references is not only able to be marked up as code, also reflects `--show-hash` option. The bug that prevented the old rdoc from correctly parsing these methods was fixed last month.
* Fix formatting errors in What's Here for Array, Hash, ENV (#5718)Burdette Lamar2022-03-251-4/+4
|
* [DOC] Repair format and links in What's Here sections (#5711)Burdette Lamar2022-03-251-124/+126
| | | | | * Repair format and links in What's Here for Comparable and Array * Repair format for What's Here in enum.c
* [Feature #18634] Implement Arrays on Variable Width AllocationPeter Zhu2022-03-221-36/+155
| | | | | | This commit implements arrays on Variable Width Allocation. This allows longer arrays to be embedded (i.e. contents directly follow the object header) which improves performance through better cache locality.
* Assume that refcnt of shared root is non-negativePeter Zhu2022-03-141-7/+5
| | | | The refcnt of a shared root array should always be non-negative.
* Assume that shared_root exists in rb_ary_decrement_sharePeter Zhu2022-03-141-5/+3
| | | | | All callers of rb_ary_decrement_share guarantee that shared_root is not 0.
* Fix crash on GC stress and RGENGC_CHECK_MODE=2Peter Zhu2022-03-121-3/+6
| | | | | | rb_ary_reset could leave the array in a bad state since it frees memory but does not unset any flags. This can cause a crash on GC stress. This commit changes rb_ary_reset to set the array as an empty embedded array.
* Add rb_ary_resetPeter Zhu2022-03-111-14/+9
| | | | rb_ary_reset will free heap allocated arrays and unshare shared arrays.
* Refactor duplicate code in rb_array_replacePeter Zhu2022-03-111-12/+7
| | | | | In both cases in the if statement, we free heap allocated arrays and unshare shared arrays.
* Use rb_ary_unshare for shared array in rb_ary_replacePeter Zhu2022-03-071-7/+1
| | | | | rb_ary_unshare will perform FL_UNSET_SHARED and rb_ary_decrement_share.
* Doc: fix documentation typo for Array#minRogerio Bordignon2022-03-031-1/+1
|
* [DOC] Fix documentation for Array#deleteVivek Bharath Akupatni2022-03-011-1/+1
| | | Never returns self.
* Use rb_ary_behead for rb_ary_shiftPeter Zhu2022-02-231-55/+28
| | | | | rb_ary_shift is just a special case of rb_ary_behead where we behead only 1 element.
* Use RARRAY_SHARED_ROOT_FLAG for checking re-enterPeter Zhu2022-02-141-3/+3
| | | | | RARRAY_SHARED_ROOT_FLAG is defined as FL_USER5, but we should use RARRAY_SHARED_ROOT_FLAG instead of depending on that they're equal.
* [DOC] Simplify operator method referencesNobuyoshi Nakada2022-02-121-8/+9
|
* [DOC] Adjustments to links in array.c (#5532)Burdette Lamar2022-02-081-13/+14
| | | Mostly suppressing links to itself.
* [DOC] Fix broken links to literals.rdocNobuyoshi Nakada2022-02-081-1/+1
|
* [DOC] Simplify links to global methodsNobuyoshi Nakada2022-02-081-1/+1
|
* [DOC] Use RDoc link style for links in the same class/modulePeter Zhu2022-02-071-10/+10
| | | | | | | | | | I used this regex: (?<=\[)#(?:class|module)-([A-Za-z]+)-label-([A-Za-z0-9\-\+]+) And performed a global find & replace for this: rdoc-ref:$1@$2
* [DOC] Use RDoc link style for links to other classes/modulesPeter Zhu2022-02-071-2/+2
| | | | | | | | | | I used this regex: ([A-Za-z]+)\.html#(?:class|module)-[A-Za-z]+-label-([A-Za-z0-9\-\+]+) And performed a global find & replace for this: rdoc-ref:$1@$2
* Adding links to literals and Kernel (#5192)Burdette Lamar2021-12-031-3/+10
| | | | * Adding links to literals and Kernel
* Use `Primitive.mandatory_only?` for `Array#sample`Koichi Sasada2021-11-151-1/+7
|
* [Feature #18290] Remove all usages of rb_gc_force_recyclePeter Zhu2021-11-081-6/+2
| | | | | This commit removes usages of rb_gc_force_recycle since it is a burden to maintain and makes changes to the GC difficult.
* Remove repeated 'the' (#4966)1809092021-10-131-1/+1
|
* Using NIL_P macro instead of `== Qnil`S.H2021-10-031-3/+3
|
* [DOC] Fix broken links [ci skip]Nobuyoshi Nakada2021-09-151-2/+2
| | | | | | * 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.
* Bsearch doc for Array and Range (#4838)Burdette Lamar2021-09-141-82/+1
| | | This PR creates doc/bsearch.rdoc to provide common documentation for bsearch in Array and Range.
* Using RB_BIGNUM_TYPE_P macroS-H-GAMELINKS2021-09-111-2/+2
|
* include/ruby/internal/intern/array.h: add doxygen卜部昌平2021-09-101-8/+0
| | | | Must not be a bad idea to improve documents. [ci skip]
* Guard array when appendingAaron Patterson2021-09-021-0/+1
| | | | | | | 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]
* Fix a code in the Array#min documentation.universato2021-08-311-2/+1
|
* Fix length calculation for Array#slice!Mike Dalessio2021-08-291-1/+1
| | | | | | | | | 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)
* Using RBOOL macroS.H2021-08-021-3/+1
|
* should not share same `def` for specialized methodKoichi Sasada2021-07-291-1/+1
| | | | | Because the key of redefine table is `def`, `def` should be unique for each optimized method (`alias` is not allowed).
* What's Here for Numeric and ComparableBurdette Lamar2021-06-211-2/+5
|
* Adjust styles [ci skip]Nobuyoshi Nakada2021-06-171-2/+4
| | | | | | | | | * --braces-after-func-def-line * --dont-cuddle-else * --procnames-start-lines * --space-after-for * --space-after-if * --space-after-while
* Do not allow array modifications after freeze inside sort!Jeremy Evans2021-05-211-2/+13
| | | | | | | | | 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]
* Fix example code in Array#max docMasataka Pocke Kuwabara2021-05-081-1/+1
| | | | | `[0, 1, 2, 3].max(6)` actually returns `[3, 2, 1, 0]`, but the doc said it returns `[3, 2, 1]`.
* Correctly update array capacity after reallocPeter Zhu2021-05-041-5/+10
| | | | | | | | | 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.
* array.c (rb_ary_zip): take only as many as needed from an Enumerator (#4389)Yusuke Endoh2021-04-211-2/+2
| | | [Bug #17814]
* Add Array#intersect?Travis Hunter2021-04-161-0/+56
|