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

784 Коммитов

Автор SHA1 Сообщение Дата
mrkn 78729a59a2 Fix rb_ary_sum for mathn
* array.c (rb_ary_sum): fix for mathn

* test/ruby/test_array.rb (test_sum): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-01 15:02:47 +00:00
akr ef6af0c967 [DOC] Arrah#sum with non-numeric objects.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-22 11:44:34 +00:00
ktsj 5e08452993 * array.c (rb_ary_sum): [DOC] fix typos.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-17 11:34:52 +00:00
akr b59a158a18 * array.c (rb_ary_sum): Don't yield same element twice.
Found by nagachika.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-15 16:26:38 +00:00
akr 72305d2531 * array.c (rb_ary_sum): Fix SEGV by [1/2r, 1].sum.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-15 16:04:18 +00:00
mrkn d1d95056a3 rename rb_rational_add -> rb_rational_plus
* rational.c (rb_rational_plus): rename from rb_rational_add
  to be aligned with rb_fix_plus.

* array.c (rb_ary_sum): ditto.

* internal.h: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-15 14:54:39 +00:00
mrkn 0a267b79f6 array.c (rb_ary_sum): use rb_rational_add directly
* rational.c (rb_rational_add): rename from nurat_add.

* array.c (rb_ary_sum): use rb_rational_add directly.

* test/ruby/test_array.rb (test_sum): add assertions for an array of
  Rational values.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-15 14:46:35 +00:00
mrkn a945eb9dda array.c: sum for Rational and Float mixed arrays
* array.c (rb_ary_sum): apply the precision compensated algorithm
  for an array in which Rational and Float values are mixed.

* test/ruby/test_array.rb (test_sum): add assertions for the above
  change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54601 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-15 13:33:05 +00:00
akr df941c91b1 [DOC]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-14 12:56:38 +00:00
akr 76426c7ea5 * array.c (rb_ary_sum): Support the optional argument, init, and block.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-14 12:48:44 +00:00
akr 350a740058 [DOC]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-14 00:00:32 +00:00
akr b359d20352 * array.c (rb_ary_sum): Array#sum is implemented.
Kahan's compensated summation algorithm for precise sum of float
  numbers is moved from ary_inject_op in enum.c.

* enum.c (ary_inject_op): Don't specialize for float numbers.

  [ruby-core:74569] [Feature#12217] proposed by mrkn.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-13 13:51:53 +00:00
mame b3a65c883a * array.c, enum.c: make rdoc format consistent.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-17 12:52:47 +00:00
mame 4ca0483a28 * array.c (rb_ary_max, rb_ary_min): implement Array#max and min with
arguments.  replace super call with rb_nmin_run.

* enum.c (nmin_run): exported (as rb_nmin_run).

* internal.h: added a prototype for rb_nmin_run.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54152 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-17 12:37:20 +00:00
mame 90ab5beb42 * array.c (rb_ary_max, rb_ary_min): implement a block by itself instead
of delegating Enumerable#max/min.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-17 12:25:40 +00:00
mame 68a6f2e9e0 * array.c (rb_ary_max, rb_ary_min): Array#max and Array#min added.
[Feature #12172]

* internal.h (OPTIMIZED_CMP): moved from enum.c so that array.c can
  use it.

* test/ruby/test_array.rb (test_max, test_min): tests for Array#max
  and Array#min.

* test/ruby/test_enum.rb (test_max, test_min): revised a bit to test
  Enumerable#max and #min explicitly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-17 12:14:21 +00:00
mame a22455199b * internal.c: struct cmp_opt_data added for refactoring out a data
structure for CMP_OPTIMIZABLE

* array.c (struct ary_sort_data): use struct cmp_opt_data.

* enum.c (struct min_t, max_t, min_max_t): use struct cmp_opt_data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-17 12:03:48 +00:00
nobu c31d06eeb7 array.c: [DOC] remove trailing comma [ci skip]
* array.c (rb_ary_push_m): [DOC] Remove trailing comma from
  Array#push example, as other Array examples doesn't put trailing
  comma.  [Fix GH-1279]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-29 07:51:15 +00:00
nobu 491c44e984 Clarify set intersection and union documentation
* array.c (rb_ary_and): clarify that set intersection returns the
  unique elements common to both arrays.

* array.c (rb_ary_or): clarify that union preserves the order from
  the given arrays.

- Most know what intersection means, but saying the operation
  excludes duplicates could be misleading ([1] & [1], duplicates
  excluded, might mean a result of []).
- Instead, saying intersection returns the unique elements common to both
  arrays is more concise and less ambiguous.
- The set union's documentation was incomplete in its describing
  preservation of order. Saying union preserves the order of the
  original array neglects the idea that the order of the elements
  in both arrays, as given, will be preserved.
- Instead, saying set union preserves the order from the given arrays (and
  adding an example) fully demonstrates the idea.

[Fix GH-1273] [ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-28 01:20:39 +00:00
nobu 4df168074c Fix a Ruby-Doc comment for Array#dig
* array.c (rb_ary_dig): [DOC] fix the exception class to be raised
  when intermediate object does not have dig method.  TypeError
  will be raised now.  [Fix GH-1224]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-27 07:26:53 +00:00
nobu 7cf2a0a1b9 array.c: reword [ci skip]
* array.c (permute0, rpermute0): [DOC] Substitute indexes ->
  indices in documentation for consistency.  [Fix GH-1222]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-26 10:37:12 +00:00
nobu 439224a590 RUBY_ASSERT
* error.c (rb_assert_failure): assertion with stack dump.
* ruby_assert.h (RUBY_ASSERT): new header for the assertion.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-22 08:33:55 +00:00
shugo 9f44b77a18 * enum.c (enum_minmax): optimize object comparison in
Enumerable#minmax.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-07 13:06:23 +00:00
marcandre cb3b463a50 * array.c: Improve and fix documentation for Array#dig
[#11776]

* hash.c: ditto

* struct.c: ditto

* test_hash.rb: Add basic test for user defined `dig`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08 05:21:11 +00:00
hsbt 65c744fb9c * array.c: clarify docs for take_while/drop_while samples.
[ci skip][fix GH-1028] Patch by @leriksen

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-20 03:53:25 +00:00
nobu 0701e5ff46 update rdoc of dig methods [ci skip]
* array.c (rb_ary_dig), hash.c (rb_hash_dig): [DOC] Update
  comments describing dig methods.  [Fix GH-1103]
* struct.c (rb_struct_dig): [DOC] add rdoc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-17 02:25:28 +00:00
nobu 29862685c0 dig
* array.c (rb_ary_dig): new method Array#dig.
* hash.c (rb_hash_dig): new method Hash#dig.
* object.c (rb_obj_dig): dig in nested arrays/hashes.
  [Feature #11643]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-09 12:27:26 +00:00
gogotanaka 0765fcf833 * array.c: clarifies Array#reject! documentation.
[fix GH-894][ci skip] Patch by @GxSplinter

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-06 14:01:30 +00:00
nobu 645116ff25 RUBY_DTRACE_CREATE_HOOK
* internal.h (RUBY_DTRACE_CREATE_HOOK): macro to call hook at
  object creation.

* vm.c (rb_source_location, rb_source_loc): retrieve source path
  and line number at once.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-29 05:32:57 +00:00
nobu 77a952d1fb adjust spaces [ci skip]
* array.c (rb_ary_collect): [DOC] Fix space of code example of
  Array#map.  [Fix GH-1062]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-22 15:19:06 +00:00
nobu 4191a6b90d preserve encodings in error messages
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-28 02:40:46 +00:00
nobu ca5c9084dc array.c: [DOC] correct Array#sort rdoc [ci skip]
* array.c (rb_ary_sort_bang, rb_ary_sort): [DOC] correct block
  return values, which may be a negative or positive integer, not
  ony -1 or +1.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-15 04:13:15 +00:00
nobu 5a0dc59a01 array.c: [DOC] correct Array#sort rdoc [ci skip]
* array.c (rb_ary_sort_bang, rb_ary_sort): [DOC] Correct
  description of array sort block return values.  And also fix up
  the grammar a bit.  [Fix GH-1020]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-15 03:49:12 +00:00
nobu 0a8a321558 array.c: fix buffer size
* array.c (rb_ary_repeated_permutation): fix buffer size, ALLOCV_N
  already multiplies element size.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-11 05:57:11 +00:00
nobu f8fb526ad9 remove needless volatile
* array.c (rb_ary_each): remove needless volatile for outdated
  clang 3.0.  revert r32201.

* cont.c (cont_capture): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-13 10:52:11 +00:00
nobu 481292190f array.c: fix memory leak
* array.c (rb_ary_sort_bang): the original array may not be
  embedded even if a substitution array is embedded, as it is
  embedded when the original array is short enough but not
  embedded.  [ruby-dev:49166] [Bug #11332]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-05 01:51:51 +00:00
nobu 4a686ebcd3 array.c: use ALLOCV_N
* array.c (rb_ary_permutation): use ALLOCV_N instead of ALLOCV.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-21 12:28:20 +00:00
nobu c54fb9ec8b array.c: fix for enumerator
* array.c (rb_ary_bsearch_index): fix function typt to return
  enumerator if no block given.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-12 08:19:24 +00:00
nobu b63391de2b array.c: typo
* array.c (rb_ary_bsearch_index): fix typo.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-12 07:40:43 +00:00
nobu c64d283f9a array.c: bsearch_index
* array.c (rb_ary_bsearch_index): Implement Array#bsearch_index
  method, which is similar to bsearch and returns the index or
  nil.  [Feature #10730]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-12 07:28:21 +00:00
nobu 37e3fec4bb array.c: fix array size overflow
* array.c (ary_ensure_room_for_push): check if array size will
  exceed maxmum size to get rid of buffer overflow.
  [ruby-dev:49043] [Bug #11235]
* array.c (ary_ensure_room_for_unshift, rb_ary_splice): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-11 04:50:22 +00:00
hsbt 5015e057fb * array.c: Revert r50763. because "reentered" is not typo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-04 04:49:26 +00:00
hsbt df55f4170a * array.c: fix a typo. Patch by @manish-shrivastava
[fix GH-922]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-04 01:54:41 +00:00
nobu d28001f01a array.c: [DOC] return values are not new array [CI SKIP]
* array.c (rb_ary_assoc, rb_ary_rassoc): [DOC] the result when key
  was found is the existing element, not a new array.  reported by
  Giau Nguyen <giaunv AT nustechnology.com>.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-15 09:28:24 +00:00
hsbt 05d1196203 * array.c: document that first element is kept when using
Array#uniq and #uniq! [fix GH-845][ci skip]
  Patch by @riffraff

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-07 00:36:09 +00:00
nobu aa436bdca6 array.c: reduce to_ary call
* array.c (flatten): no need to call to_ary method on elements
  beyond the given level.  [ruby-core:67637] [Bug #10748]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-25 03:04:10 +00:00
nobu 5ec029d1ea array.c: linear performance
* array.c (rb_ary_select_bang, ary_reject_bang): linear
  performance.  [ruby-core:67418] [Feature #10714]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-15 01:44:57 +00:00
hsbt 2f7e05b1b5 * array.c (rb_ary_each): documented return value.
[misc #10469][ruby-core:66063]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-12 04:33:57 +00:00
nobu e19cf850df array.c: trivial optimizations
* array.c (rb_ary_bsearch): trivial optimizations, for Fixnum, and
  by keeping the last satisfied element.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-12 01:25:26 +00:00
nobu 4d69e03b66 array.c: class name encoding
* array.c (rb_ary_bsearch): preserve encoding of class name in an
  exception message.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49215 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-11 23:48:10 +00:00
nobu d2da3d04e6 array.c: keep consistency
* array.c (rb_ary_select_bang): keep the array consistent by
  removing unselected values soon.  [ruby-dev:48805] [Bug #10722]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-10 01:12:17 +00:00
ayumin b600ceb898 * array.c: improve docs for Array#reject. [ruby-core:65324][misc #10307]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-04 03:45:24 +00:00
hsbt 574422733d * array.c: Improve performance of Array#shift. use shared instead of
MEMMOVE if with arguments. Patch by @ksss [fix GH-537]
* test/ruby/test_array.rb: ditto.
* benchmark/bm_array_shift.rb: Added benchmark of GH-537 issue.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-03 02:27:50 +00:00
nobu 820e5ade8b array.c: decoration
* array.c (rb_ary_plus): inline decoration of the operator.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-02 06:59:25 +00:00
duerst 24f5f816ff array.c (rb_ary_plus): in documentation, added note about
inefficiency of repeated += operations. [ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-02 06:30:05 +00:00
akr 7cd76ab0c5 * internal.h: Include ruby.h and ruby/encoding.h to be
includable without prior inclusion.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15 11:49:06 +00:00
normal eb5147779d array.c: swap volatile for RB_GC_GUARD
* array.c (ary_recycle_hash): add RB_GC_GUARD
  (rb_ary_diff): remove volatile
  [Bug #10369]

The RB_GC_GUARD seems needed for most of the ary_recycle_hash
functions anyways.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-12 21:53:01 +00:00
nobu 795b8b474c internal.h: optimize rb_ary_new_from_args
* internal.h (rb_ary_new_from_args): optimization by expanding
  arguments in caller to get rid of va_list if possible.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-09 07:53:54 +00:00
nobu 4adfbab35c array.c: fix potential memory leak
* array.c (ary_new): allocate buffer in heap after new object get
  allocated successfully, to get rid of potential memory leak at
  object allocation failure.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47855 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-09 04:35:12 +00:00
nobu 88cbfc0d10 array.c: GC guard
* array.c (rb_ary_splice): prevent replacing array from GC.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-22 08:17:24 +00:00
glass e539565d9a * array.c: use rb_equal_opt() for performance improvement.
[ruby-core:64954] [Feature #10227]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-21 02:23:32 +00:00
ko1 123eeb1c1a * gc.c: add incremental GC algorithm. [Feature #10137]
Please refer this ticket for details.
  This change also introduces the following changes.
  * Remove RGENGC_AGE2_PROMOTION and introduce object age (0 to 3).
    Age can be count with FL_PROMOTE0 and FL_PROMOTE1 flags in
    RBasic::flags (2 bit). Age == 3 objects become old objects.
  * WB_PROTECTED flag in RBasic to WB_UNPROTECTED bitmap.
  * LONG_LIVED bitmap to represent living objects while minor GCs
    It specifies (1) Old objects and (2) remembered shady objects.
  * Introduce rb_objspace_t::marked_objects which counts marked
    objects in current marking phase. marking count is needed to
    introduce incremental marking.
  * rename mark related function and sweep related function to
    gc_(marks|sweep)_(start|finish|step|rest|continue).
  * rename rgengc_report() to gc_report().
  * Add obj_info() function to get cstr of object details.
  * Add MEASURE_LINE() macro to measure execution time of specific line.
  * and many small fixes.
* include/ruby/ruby.h: add flag USE_RINCGC.
  Now USE_RINCGC can be set only with USE_RGENGC.
* include/ruby/ruby.h: introduce FL_PROMOTED0 and add FL_PROMOTED1
  to count object age.
* include/ruby/ruby.h: rewrite write barriers for incremental marking.
* debug.c: catch up flag name changes.
* internal.h: add rb_gc_writebarrier_remember() instead of
  rb_gc_writebarrier_remember_promoted().
* array.c (ary_memcpy0): use rb_gc_writebarrier_remember().
* array.c (rb_ary_modify): ditto.
* hash.c (rb_hash_keys): ditto.
* hash.c (rb_hash_values): ditto.
* object.c (init_copy): use rb_copy_wb_protected_attribute() because
  FL_WB_PROTECTED is moved from RBasic::flags.
* test/objspace/test_objspace.rb: catch up ObjectSpace.dump() changes.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-08 04:11:00 +00:00
ko1 b5e89e44f1 * array.c (rb_ary_tmp_new): added.
This function creates internal use only array (which is completely
  hided by ObjectSpace.each_object) with filling nil.
  Otherwise, it can be incldues strange VALUEs.
* internal.h: added.
* node.h: use rb_ary_tmp_new_fill() for MEMO.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-15 10:32:58 +00:00
nobu a6ba688db3 array.c: array may be modified in the block
* array.c (rb_ary_any_p): the array may be modified in the yielded
  block, do not access directly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-18 14:24:48 +00:00
nobu d738e3e155 optimized any? methods
* array.c (rb_ary_any_p), hash.c (rb_hash_any_p): optimized
  versions.  these are bit faster than optimization in
  Enumerable#any?.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-18 13:16:48 +00:00
hsbt 94bbd10ea7 * array.c: Clarify documentation for Array#insert.
[ruby-core:62934] [Bug #9901]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-11 07:00:49 +00:00
nobu e99ee55abc constify parameters
* include/ruby/intern.h: constify `argv` parameters.

* include/ruby/ruby.h: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-18 06:16:39 +00:00
nobu b654e0719a array.c: non-recursive rcombinate0
* array.c (rcombinate0): remove recursion, by looping with indexes
  stored in `p`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-14 01:55:25 +00:00
nobu 4802149e44 array.c: non-recursive rpermute0
* array.c (rpermute0): remove recursion, by looping with indexes
  stored in `p`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-14 01:55:07 +00:00
nobu 9d6b7aede9 array.c: non-recursive permute0
* array.c (permute0): remove recursion, by looping with indexes
  stored in `p`.  [ruby-core:63103] [Bug #9932]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-14 01:54:45 +00:00
nobu 02725fb682 array.c: combinate0
* array.c (combinate0): extract.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-14 01:54:33 +00:00
nobu 537b4a6422 array.c: combination on a shared copy
* array.c (rb_ary_combination): iterate on a shared copy, and use
  array of indexes instead of array of chosen objects.
  [ruby-core:63149] [Bug #9939]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-13 08:34:17 +00:00
nobu 95bac4f75e array.c: yield_indexed_values
* array.c (yield_indexed_values): extract from permute0(),
  rpermute0(), and rcombinate0().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-13 08:33:58 +00:00
nobu e6f1557562 array.c: fix array size
* array.c (rb_ary_permutation): `p` is the array of size `r`, as
  commented at permute0().  since `n >= r` here, buffer overflow
  never happened, just reduce unnecessary allocation though.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-13 04:43:57 +00:00
zzak f1d6b82981 * array.c: [DOC] Clarify default argument for Array.new.
By @Elffers [Fixes GH-610] [ci skip]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-24 21:30:42 +00:00
hsbt 2091ccac88 * array.c: [DOC] Add more documents to shuffle! and shuffle.
Contributed by @JuanitoFatas [ci skip][fix GH-612]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-24 13:40:28 +00:00
nobu 7f3b12f05b use predefined IDs
* array.c (rb_ary_equal), hash.c (hash_equal): use predefined IDs,
  `to_ary` and `to_hash` respectively.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-20 08:28:31 +00:00
ko1 f2606d6250 * array.c (ARY_SET): added.
ARY_SET() is same functionality of RARRAY_ASET(), but
  it has an assertion (`ary' doesn't have shared array).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-11 09:55:10 +00:00
ko1 6bc463204a * array.c: make shared arrays WB-protected objects.
Shared arrays were WB-unprotected object because
  sharing array can modify shared array's buffer
  if it occupied shared array.
  [sharing array (ary)] -> [shared array (shared)] -> <buff>
                |                                       A
                +---------------------------------------+
             write `buff' with WB(ary, &buff[i], obj)
             -> if `ary' and `shared' are old, then only `ary'
                will be remembered.
             -> traverse from `ary'. But `shared' is old, so
                that written `obj' is not marked.
  It cause WB miss so that shared arrays were WB-unprotected.
  (WB-unprotected objects are marked everytime if it is living)
  This patch insert WB() for `shared' if it is needed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-11 08:47:00 +00:00
nobu 153fa25658 array.c: maybe shared array
* array.c (ary_reject): may be turned into a shared array during
  the given block.  [ruby-dev:48101] [Bug #9727]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-11 03:44:52 +00:00
ko1 f19bf5ba5a * array.c (rb_ary_modify): remember shared array owner if a shared
array owner is promoted and a shared array is not promoted.
  Now, shared array is WB-unprotected so that shared arrays are not
  promoted.  All objects referred from shared array should be marked
  correctly.
  [ruby-core:61919] [ruby-trunk - Bug #9718]
* test/ruby/test_array.rb: add a test for above.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-10 10:16:24 +00:00
nobu fc23374f06 [DOC] add links to `Object#hash`
add links to `Object#hash` to each #`hash` methods rdocs.
[Fixes GH-567]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-14 01:27:43 +00:00
nobu 78b1ca9f0f array.c: comment why rb_ary_modify is needed twice
* array.c (rb_ary_initialize): NUM2LONG() may call size.to_int,
  ary can be frozen, modified, etc, so recheck after argument
  conversion is necessary.  [Closes GH-526]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44855 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-06 01:31:27 +00:00
marcandre e030b4ee79 * array.c: rdoc clarification for <=>
* file.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-09 17:33:47 +00:00
tmm1 3cf4fe47e8 array.c: return first unique element in Array#uniq
* array.c (ary_add_hash): Fix consistency issue between Array#uniq and
  Array#uniq! [Bug #9340] [ruby-core:59457]
* test/ruby/test_array.rb (class TestArray): regression test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-06 19:38:20 +00:00
glass 56b0396944 * array.c (rb_ary_zip): use ALLOCV_N() instead of ALLOCA_N().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-01 15:55:51 +00:00
marcandre 9471f4187f * array.c: Have to_h raise on elements that are not key-value pairs [#9239]
* enum.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-23 03:42:29 +00:00
ko1 c702005a7b * include/ruby/ruby.h: rename OBJ_WRITE and OBJ_WRITTEN into
RB_OBJ_WRITE and RB_OBJ_WRITTEN.
* array.c, class.c, compile.c, hash.c, internal.h, iseq.c,
  proc.c, process.c, re.c, string.c, variable.c, vm.c,
  vm_eval.c, vm_insnhelper.c, vm_insnhelper.h,
  vm_method.c: catch up this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-20 08:07:47 +00:00
ko1 3477670963 * array.c: fix comment to remove the word "shady".
* variable.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-13 02:53:27 +00:00
marcandre e91ccb6c67 * array.c: More doc examples for Array#{map|collect}{!} using both forms
* enum.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-11 19:55:56 +00:00
nobu 037a9d0655 array.c, hash.c: add salt
* array.c (rb_ary_hash): add salt to differentiate false and empty
  array.  [ruby-core:58993] [Bug #9231]
* hash.c (rb_any_hash, rb_hash_hash): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44125 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-10 14:44:51 +00:00
nobu 1018f57f2c array.c: id_random
* array.c (rb_ary_shuffle_bang, rb_ary_sample): share id_random
  instead of no longer used sym_random.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44066 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-08 06:47:39 +00:00
ktsj 7f5a9f3881 * array.c (rb_ary_shuffle_bang, rb_ary_sample): rename local variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44065 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-08 05:58:17 +00:00
ktsj 3e1360f370 * array.c (rb_ary_shuffle_bang, rb_ary_sample): check
unknown keywords.

* test/ruby/test_array.rb (test_shuffle, test_sample): tests for
  the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-08 05:02:12 +00:00
charliesome e0290c9404 * array.c (rb_ary_or): use RHASH_TBL_RAW instead of RHASH_TBL
* process.c (rb_execarg_fixup): use RHASH_TBL_RAW and insert write
  barriers where appropriate

* vm.c (kwmerge_i): use RHASH_TBL_RAW

* vm.c (HASH_ASET): use rb_hash_aset instead of calling directly into
  st_insert

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44052 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-08 00:41:01 +00:00
nobu 19737494b9 array.c: prefer lhs elements
* array.c (rb_ary_or): lhs elements are prefered, so should not
  replace with rhs elements.
* test/ruby/test_array.rb (test_OR_in_order): import the test failed
  by r43969 from rubyspec/core/array/union_spec.rb.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-05 12:53:31 +00:00
nobu 6f2efe84fb hash.c: detect recursion for all
* hash.c (rb_hash): detect recursion for all `hash' methods.  each
  `hash' methods no longer need to use rb_exec_recursive().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-03 13:18:30 +00:00
glass 2b07df37d1 * array.c (rb_ary_uniq_bang): remove duplicate code.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-03 05:13:19 +00:00
glass 95f983f6d0 * array.c (ary_add_hash): set and return values because string keys
will be frozen. [ruby-core:58809] [Bug #9202]

* array.c (rb_ary_uniq_bang): ditto.

* array.c (rb_ary_or): ditto.

* array.c (rb_ary_uniq): ditto.

* test/ruby/test_array.rb: tests for above.

The patch is from normalperson (Eric Wong).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43969 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-03 04:55:51 +00:00
nobu 7566c49068 ruby/ruby.h: RB_BLOCK_CALL_FUNC_ARGLIST
* include/ruby/ruby.h (RB_BLOCK_CALL_FUNC_ARGLIST): for declaration
  argument list of rb_block_call_func.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-29 07:59:14 +00:00