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

486 Коммитов

Автор SHA1 Сообщение Дата
nobu 8554e16355 * array.c (rb_ary_{shuffle_bang,sample}): use Random class object.
* random.c (try_get_rnd): use default_rand for Random as same as
  singleton methods.

* random.c (rb_random_real): check the range of result.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-25 22:30:03 +00:00
shyouhei 2531892cbc reverted to r29091; r29092 breaks test-all
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-25 12:14:38 +00:00
nobu ae6a9009dc * array.c (rb_ary_{shuffle_bang,sample}): use Random class object.
* random.c (try_get_rnd): use default_rand for Random as same as
  singleton methods.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-25 09:00:17 +00:00
nobu 569d821929 * array.c (rb_ary_sample): use frozen shared array to get rid of
reallocation.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29092 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-25 08:56:47 +00:00
nobu 2f6c0e3be3 * array.c (rb_ary_shuffle_bang, rb_ary_sample): add optional
argument random.  [ruby-dev:41923] [EXPERIMENTAL]

* random.c (rb_random_{int32,real,bytes}): fallback to normal
  method invocation.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-23 22:07:39 +00:00
nobu 119da02e87 * array.c (RAND_UPTO): macro for random number.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-21 21:46:31 +00:00
mrkn 1d04aedb5a * array.c (rb_ary_permutation, rb_ary_repeated_permutation, rb_ary_repeated_combination, rb_ary_product): use ary_make_shared_copy instead of ary_make_substitution. [ruby-dev:42067] [Bug #3708]
* test/ruby/test_array.rb (test_product, test_repeated_permutation, test_repeated_combination): append assertions against [Bug #3708].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-19 03:10:15 +00:00
mrkn 354e376028 forget to commit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-18 10:13:54 +00:00
mrkn 4023ffa92f * array.c (ary_make_shared), test/ruby/test_array.rb (test_permutation): always return the original array when it is shared. [ruby-dev:42067] [Bug #3708]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-18 09:42:36 +00:00
nobu dccf9e0c45 * configure.in, include/ruby/defines.h (RUBY_FUNC_EXPORTED): macro
to declare exported function.

* array.c (rb_ary_memsize), string.c (rb_str_memsize),
  variable.c (rb_objspace_data_type_memsize): used in
  objspace.  [ruby-dev:42022]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-14 06:33:06 +00:00
nobu 87d8a3b9ce * array.c (rb_ary_clear): should not unshare embedded array, and
should make unshared array embedded.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-19 03:33:33 +00:00
nobu 10a90fbce8 * array.c (rb_ary_clear): no need to duplicate buffer just before
clearing.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-18 12:20:14 +00:00
akr 58772d7110 * array.c (rb_ary_product): clear uninitialized elements in temporary
array.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-06-06 10:56:45 +00:00
nobu c22b223cb0 * array.c (rb_ary_product): need to set the length in order to get
the entries marked.  [ruby-dev:41540]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-06-06 01:44:38 +00:00
nobu 45f6fbf339 * removed trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-29 18:51:39 +00:00
shyouhei 11cef3cca3 * array.c (rb_ary_product): Use tmpary instead, to ensure marking
arrays by GC.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-28 08:51:41 +00:00
shyouhei 97b1c9edd2 * array.c (rb_ary_product): Do not rely on GC, t0 should be
checked explicitly.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-28 02:43:34 +00:00
marcandre 7729de4d91 * array.c: Documentation: change => in call-seq to ->.
Harmonize "#=>" in examples. [ruby-core:30206]

* bignum.c: ditto

* class.c: ditto

* compar.c: ditto

* cont.c: ditto

* dir.c: ditto

* encoding.c: ditto

* enum.c: ditto

* enumerator.c: ditto

* error.c: ditto

* eval.c: ditto

* file.c: ditto

* gc.c: ditto

* io.c: ditto

* load.c: ditto

* marshal.c: ditto

* math.c: ditto

* numeric.c: ditto

* object.c: ditto

* pack.c: ditto

* proc.c: ditto

* process.c: ditto

* random.c: ditto

* range.c: ditto

* re.c: ditto

* ruby.c: ditto

* signal.c: ditto

* sprintf.c: ditto

* string.c: ditto

* struct.c: ditto

* thread.c: ditto

* time.c: ditto

* transcode.c: ditto

* variable.c: ditto

* vm_eval.c: ditto

* vm_method.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-17 21:07:33 +00:00
marcandre 4afa9ed041 * array.c: Harmonize documentation, in particular regarding:
- methods returning enumerators
    - array methods and argument naming (array -> ary, an_array -> new_ary)
    - minor improvements, typo fixed and styling issues

  Other documentation errors fixed:
    - return value was self instead of a new array (or vice-versa) for
      Array#{pop,shift,permutation,repeated_permutation,keep_if}
    - Array#rindex was missing the form with a block.

* dir.c: ditto.

* enum.c: ditto. Modified Enumerable#reverse_each' documentation to clarify
  that #each will be finish before any element is yielded.

* error.c: ditto.

* gc.c: ditto.

* hash.c: ditto.

* io.c: ditto. IO#{codepoints,each_codepoint} fixed as per [ruby-core:23948]

* numeric.c: ditto.

* range.c: ditto.

* string.c: ditto.

* struct.c: ditto.

* vm_eval.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-13 05:49:55 +00:00
marcandre b140b77926 * array.c (rb_ary_fetch, rb_ary_splice, rb_ary_store): Improve IndexError
messages [ruby-core:28394]

* hash.c (rb_hash_fetch_m): Improve KeyError message

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-08 04:49:53 +00:00
matz 38ae996706 * array.c (rb_ary_repeated_permutation): new method added. a patch
from Makoto Kishimoto in [ruby-core:29267]   [ruby-core:28724]

* array.c (rb_ary_repeated_combination): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-16 07:24:04 +00:00
marcandre f3d2f9e4d1 * array.c (rb_ary_permutation): Remove limitation for lengthy permutations
[ruby-core:29240]

* test/ruby/test_array.rb: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-07 17:36:15 +00:00
marcandre 93f4317f89 * array.c (rb_ary_product): Don't limit based on size when a block is given
cf [ruby-core:29240]

* test/ruby/test_array.rb (class): Test for above

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-03 20:59:56 +00:00
marcandre 94ab139bc9 * array.c (rb_ary_product): Make defensive copy in case of block...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-02 22:44:17 +00:00
marcandre d0a98a0e90 * array.c (rb_ary_product): Test for reentry
* test/ruby/test_array.rb: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-02 22:25:49 +00:00
marcandre 7cf6ecd9de * array.c (rb_ary_product): Accept a block [ruby-core:29045]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-02 21:56:34 +00:00
akr 9ce419a45c * array.c (rb_ary_uniq_bang): the array is already unique if the
length is zero or one.
  (rb_ary_uniq): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-20 04:27:32 +00:00
matz 8b55878d2a * enum.c (enum_join): remove Enumerable#join. [ruby-core:24786]
* array.c (ary_join_1): use #to_ary to detect recursive array.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-13 05:55:46 +00:00
matz 006a8ba77f * array.c (rb_ary_select_bang): select! removes all elements for
which block returns false.  [ruby-core:27286]

* array.c (rb_ary_keep_if): #keep_if, new method.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-03 05:35:08 +00:00
naruse 6b6a41d1e7 * array.c (rb_ary_push_m): use rb_ary_modify instead of
rb_ary_modify_check.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-15 04:13:43 +00:00
matz 5d325e6a9e * array.c (rb_ary_delete): RDoc update. a patch from Hugh Sasse.
[ruby-core:28128]

* array.c (rb_ary_compact_bang): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-13 08:08:19 +00:00
nobu f3f43cdbee * array.c (rb_ary_push_m, rb_ary_unshift_m, rb_ary_aset),
(rb_ary_insert, rb_ary_replace, rb_ary_concat),
  (rb_ary_uniq_bang, rb_ary_flatten_bang): check if frozen after
  wrong number of arguments but before TypeError.
  [ruby-core:28140]

* hash.c (rb_hash_replace): ditto.

* string.c (rb_str_replace): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26632 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-10 07:31:06 +00:00
nobu 8a4c9b0b77 * array.c (rb_ary_rotate): new methods, Array#rotate! and
Array#rotate.  [ruby-dev:17194]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-21 02:15:48 +00:00
nobu 2cb9f63bab * array.c (rb_ary_reverse_m): copy directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26365 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-21 02:12:07 +00:00
matz 0580ba0611 * array.c (rb_ary_to_ary): do not use #respond_to? to detect
to_ary.  Just call.  [ruby-core:23738]

* eval.c (rb_check_funcall): new function with method existence
  check.  returns Qundef when the method does not exist.

* enumerator.c (enumerator_rewind): just call method, using
  rb_check_funcall().  [ruby-core:23738]

* error.c (exc_equal): ditto.

* object.c (convert_type): ditto.

* error.c (rb_name_err_mesg_new): export function.

* eval.c (make_exception): ditto.

* io.c (pop_last_hash): return early when the last argument is nil.

* io.c (rb_io_puts): treat T_STRING specially for small
  optimization. 

* vm_eval.c (raise_method_missing): skip method call if possible
  using rb_method_basic_definition_p().

* vm_eval.c (method_missing): ditto.

* test/ruby/test_rubyoptions.rb (TestRubyOptions#test_debug): test
  suites changed to ignore exceptions caused by just-call policy.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-29 04:55:10 +00:00
marcandre 705c567194 * string.c: rdoc for <=>, casecmp
* bignum.c: rdoc for <=>

* file.c: ditto

* time.c: ditto

* compar.c: rdoc

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-28 04:50:09 +00:00
marcandre 8d446fe1eb * array.c (rb_ary_cmp): Array#<=> returns nil when comparison fails
[ruby-core:26316]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25491 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-26 11:06:17 +00:00
matz 40229f892c * array.c (rb_ary_{times, shuffle_bang, sample}): reducing macro
calls inside of the loop by keeping pointers in local
  variables. a patch from Masahiro Kanai (CanI) in [ruby-dev:39406].
  It was found and fixed at Security and Programming camp 2009.

* string.c (rb_str_{times, split_m}): ditto.

* struct.c (rb_struct_{getmember, set, aref_id, aset_id}, {make,
  inspect}_struct, recursive_{equal, hash, eql}): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-05 14:35:39 +00:00
nobu 1a78256861 * array.c (ary_make_shared): should count frozen array itself.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-02 17:49:52 +00:00
marcandre 1796522f10 * thread.c (rb_exec_recursive_outer, rb_exec_recursive): Added method to short-circuit to the outermost level in case of recursion
* test/ruby/test_thread.rb (test_recursive_outer): Test for above

* hash.c (rb_hash_hash): Return a sensible hash for in case of recursion [ruby-core:24648]

* range.c (rb_range_hash): ditto

* struct.c (rb_struct_hash): ditto

* array.c (rb_array_hash): ditto

* test/ruby/test_array.rb (test_hash2): test for above

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-15 21:30:50 +00:00
nobu 31b7ae00c0 * include/ruby/st.h (st_hash_func): use st_index_t.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-08 13:10:04 +00:00
nobu 34401f9014 * array.c (permute0): use chars for boolean array.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24365 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-03 06:56:57 +00:00
nobu 49816a2552 * array.c (rb_ary_{permutation,combination}): disallow reentrance
with continuation since work-buffers cannot restore.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-03 06:48:46 +00:00
nobu 330be69e43 * array.c (rb_ary_{permutation,combination,product}): must not use
ary_discard on strings.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-03 04:05:37 +00:00
nobu 3770ac98ff * array.c (rb_ary_combination, rb_ary_product): prevent from GC.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-02 11:09:12 +00:00
nobu 0f6d9dfc96 * array.c: suppressed shorten-64-to-32 warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-18 07:22:42 +00:00
akr 0101958745 * array.c (recursive_hash): reject recursive key.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-17 07:49:06 +00:00
matz ae487eda6e * array.c (recursive_join): raise ArgumentError for joining
recursive array.

* array.c (ary_join_1): ditto.

* test/ruby/test_array.rb (TestArray#test_join2): test updated for
  recursive join.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-17 02:04:37 +00:00
matz 57264a4fae * array.c (rb_ary_sample): RDoc update. a patch from Florian
Frank.   [ruby-core:24347]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-16 05:10:18 +00:00
nobu 38867cc115 * array.c (ary_join_1): should recurse for element array.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24026 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-10 15:11:43 +00:00
nobu af8f8e5b0e * array.c (recursive_join): use obj to tell if recursion occurs.
[ruby-core:24150]

* enum.c (enum_join): reverted r23966.  [ruby-core:24196]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-10 07:30:08 +00:00
matz 9d9986d25c * enum.c (enum_join): add Enumerable#join.
* array.c (ary_join_1): recursive join for Enumerators (and
  objects with #to_a).

* array.c (rb_ary_join): performance tune.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23951 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-03 18:14:33 +00:00
ko1 3caa4ee5e5 * array.c (rb_ary_memsize): added.
* io.c (rb_io_memsize): added.
* regcomp.c (onig_memsize): added.
* string.c (rb_str_memsize): added.
* transcode.c (rb_transcoding_memsize, rb_econv_memsize): added.
* variable.c (rb_geneic_ivar_memsize): added.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-16 22:36:27 +00:00
nobu 02fb261ec1 * thread.c (rb_exec_recursive_paired): new function for proper
handling of recursive arrays.  [EXPERIMENTAL] [ruby-core:23402]

* array.c (rb_ary_equal, rb_ary_eql, rb_ary_cmp): use above.

* hash.c (hash_equal): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-24 13:48:23 +00:00
matz 58949cf8f3 * array.c (rb_ary_slice_bang): avoid call of rb_scan_args() unless
it's really necessary.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-21 22:35:43 +00:00
nobu 62e5fa1737 * array.c (rb_ary_shift, rb_ary_shift_m): clears unused elements.
[ruby-dev:38448]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-15 08:35:35 +00:00
akr e9e7e62025 rename argument name.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-09 05:44:20 +00:00
nobu 0d9c4400fc * array.c (rb_ary_flatten_bang): clears temporary array.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23367 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-08 01:07:03 +00:00
nobu 94ee3e7e02 * array.c (rb_ary_flatten_bang): returns nil if nothing changed.
a patch from Marc-Andre Lafortune in [ruby-core:23382].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-07 07:40:11 +00:00
nobu 9936642c40 * array.c (rb_ary_sample): negative sample number is invalid.
[ruby-core:23374]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-07 05:26:16 +00:00
nobu e4d687f372 * array.c (Init_Array): made #to_s an alias to #inspect to reduce
the result of recursive array.  a patch from ujihisa at
  [ruby-dev:38362]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23324 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-02 00:19:41 +00:00
nobu 1f6f4e6b59 * array.c: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-02 00:13:45 +00:00
matz 8e75f9705f * array.c (rb_ary_push): bypass rb_ary_store().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-04-20 22:09:30 +00:00
mame bded3bb726 * array.c (rb_ary_flatten): flatten(0) works as Array#dup.
[ruby-core:23168]

* test/ruby/test_array.rb: add a test for above.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23191 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-04-15 11:47:54 +00:00
nobu d1abc53721 * array.c, bignum.c, dln.c, error.c, gc.c, io.c, marshal.c,
numeric.c, pack.c, strftime.c, string.c, thread.c, transcode.c,
  transcode_data.h, util.c, variable.c, vm_dump.c,
  include/ruby/encoding.h, missing/crypt.c, missing/vsnprintf.c:
  suppress VC type warnings.  [ruby-core:22726]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-12 09:16:15 +00:00
nobu 2e54fe9d4d * array.c, bignum.c, gc.c, numeric.c, string.c, util.c, insns.def,
missing/crypt.c, missing/vsnprintf.c, : suppress warnings.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-10 05:43:14 +00:00
matz 60d2f945fb * array.c (rb_ary_fill): doc for Array#fill misses indication
about negative value for the start argument.  [ruby-core:22497]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22787 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-06 04:12:56 +00:00
knu 0d0d5e9f71 * array.c (rb_ary_index, rb_ary_rindex): Emit a warning that a
given block is unused when an argument is specified.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-24 15:02:01 +00:00
knu 1a1990df71 * array.c (rb_ary_index, rb_ary_rindex): We know that argc is not
zero when we reach here.

* array.c (rb_ary_initialize, rb_ary_index): Shrink a double
  space. (NFC)



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-23 06:54:58 +00:00
nobu 12d2c8ba41 stripped trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-22 14:23:33 +00:00
nobu 1128e61562 * array.c (rb_ary_resurrect), string.c (rb_str_resurrect): new
functions based on [ruby-dev:37983]

* insns.def (putstring, duparray): use rb_{ary,str}_resurrect().

* iseq.c (iseq_data_to_ary): needs to result TS_VALUE.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-18 05:33:36 +00:00
mame e722ad99d5 * string.c (rb_hash_uint32, rb_hash_uint, rb_hash_start, rb_hash_end),
include/ruby/intern.h: add Murmurhash API.  [ruby-dev:37784]

* complex.c (nucomp_hash), array.c (rb_ary_hash), time.c (time_hash),
  string.c (rb_str_hsah), object.c (rb_obj_hash), range.c
  (range_hash), struct.c (rb_struct_hash), hash.c (rb_any_hash),
  rational.c (nurat_hash): use Murmurhash.  [ruby-dev:37784]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22317 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-14 19:55:34 +00:00
nobu 766df600db * array.c (rb_ary_uniq_bang, rb_ary_uniq): unique by the result of
given block.  [ruby-dev:37998]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-14 15:45:43 +00:00
nobu e1646e639a * array.c (ary_resize_capa): should not overwrite outside embedded
array.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-14 15:39:46 +00:00
nobu f23292afb4 * array.c (ary_make_shared): returns shared root array itself, and
frozen array can be shared.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22231 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-11 06:47:12 +00:00
nobu a2c7fdc709 * array.c (rb_ary_uniq): gets rid of copying.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-05 03:24:20 +00:00
nobu e3c8cdca44 * array.c (ary_add_hash): split from ary_make_hash().
* array.c (ary_recycle_hash): clears internally used hash.  this
  name came from [ruby-dev:37908].

* array.c (rb_ary_diff, rb_ary_and, rb_ary_or, rb_ary_uniq_bang):
  recycle hashes.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-05 03:01:55 +00:00
nobu 8b093ebc3c * array.c (ary_make_hash): hide a Hash used internally.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-05 02:37:49 +00:00
kazu 2b692644d9 * NEWS: add Array#sort_by!.
* array.c (rb_ary_sort_by_bang): RDoc update.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-03 07:36:55 +00:00
matz 092861f37d * array.c (rb_ary_sort_by_bang): RDoc update. [ruby-core:21742]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-02 12:05:06 +00:00
matz 765a6be700 * array.c (rb_ary_sort_by_bang): new method. requested in
[ruby-core:21709]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-02 10:43:27 +00:00
nobu c330fb421e * array.c (rb_ary_aset): fixed arguments evaluation order.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-26 07:00:43 +00:00
matz d47e8e81a0 * array.c (ary_double_capa): a new function to expand array more
aggressively.   [ruby-core:21460]

* array.c (rb_ary_store): use ary_double_capa().

* array.c (rb_ary_unshift_m): ditto.

* array.c (rb_ary_splice): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-21 15:27:35 +00:00
usa 6ff613fc09 * array.c (take_items): to_ary() raises ArgumentError if cannot to
convert to Array. [ruby-dev:37797]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-21 05:43:04 +00:00
nobu cab67c3197 * array.c (take_items), enum.c (enum_zip): tries to convert to
array first.  [ruby-core:21442]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-19 21:47:48 +00:00
matz 8fb2235f48 * array.c (rb_ary_push_m): add modification check before actual
operation.   [ruby-dev:37440]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-17 06:56:42 +00:00
matz a89d928bfb * array.c (rb_ary_pop_m): use enum ary_take_pos_flags.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-17 06:52:18 +00:00
matz 405b527276 * array.c (rb_ary_times): taint (and untrust) status should be
inherited by "ary * 0".  [ruby-dev:37024]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20356 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-25 14:29:39 +00:00
yugui 16285e768e merges r20050 from ruby_1_9_1 into trunk.
* array.c (rb_ary_sort_bang): refactoring.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-08 11:09:20 +00:00
nobu 4927a7c77a * array.c (rb_ary_join): do not repeat self in a recursive array.
[ruby-dev:37019]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-03 18:28:34 +00:00
yugui c2ded64653 * array.c (rb_ary_take_first_or_last): renamed rb_ary_partial more
appropriately.
  (ary_take_pos_flags): new enum. makes the fourth argument of
  rb_ary_take_first_or_last more descriptive.
  (rb_ary_partial): renamed rb_ary_partial0 more appropriately.
  takes a new parameter klass for what class to instanciate.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-03 04:13:04 +00:00
yugui b4729e2db3 * array.c (ary_partial0): recovers mistakenly feature change at r19723.
Array#[m,n] had returned an Array even for an instance of a
  subclass.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-31 09:46:31 +00:00
wanabe 5eacf68c2a * array.c (rb_ary_decrement_share): fix to work recycling
shared-array without the following.  [ruby-dev:36991]

* array.c (ary_make_substitution): don't recycle substitution array.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-31 03:49:29 +00:00
mame ea4ae3302d * array.c (rb_ary_permutation): hide temporal array.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-30 12:35:04 +00:00
mame e2cb0b9766 * array.c (rb_ary_sort_bang): remove SEGV when replacing array with
embedded one during sort.

* test/ruby/test_array.rb (test_sort!): add tests for above.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-29 17:24:44 +00:00
mame 2e51b7f9da * array.c (rb_ary_splice): remove redundant check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-29 16:35:47 +00:00
mame 0d83c7b6c2 * array.c (rb_ary_sort_bang): replacing array during sort broke
invariant of array.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20026 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-29 14:58:30 +00:00
mame 2a3d7b5992 * revert the previous wrong commit; sorry.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-29 14:40:31 +00:00
mame 7451e34428 * array.c (rb_ary_sort_bang): replacing array during sort broke
invariant of array.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-29 14:30:07 +00:00
nobu 4f577310ce * array.c (rb_ary_sample): fixed sizes and randomness.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19924 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-24 15:14:44 +00:00