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

540 Коммитов

Автор SHA1 Сообщение Дата
ktsj e4811dc697 * array.c: fix rdoc. [ruby-core:53485] [ruby-trunk - Bug #8108]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-17 01:34:20 +00:00
zzak e563e6bf10 * array.c: typo in comment patch by Nami-Doc [Github fixes #253]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-01 17:46:40 +00:00
marcandre a6d08b450c * array.c: Fix rdoc for flatten!
* hash.c: Correct rdoc for reject!

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39442 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-23 20:17:20 +00:00
zzak c2204ca328 * array.c: Document #<=> return values and formatting
* bignum.c: ditto
* file.c: ditto
* object.c: ditto
* numeric.c: ditto
* rational.c: ditto
* string.c: ditto
* time.c: ditto


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-23 03:35:38 +00:00
zzak 933ff1d6d7 * array.c (rb_ary_diff, rb_ary_and, rb_ary_or): Document return order
[RubySpec #7803


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-23 02:50:34 +00:00
eregon 92abfccaa3 * array.c: Fix typo in class documentation
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-19 16:19:13 +00:00
zzak 281e6e1b3b * object.c: rdoc formatting for Kernel#Array()
* array.c: Add rdoc for Array() method to Creating Arrays section


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-19 03:32:11 +00:00
usa 450a515e95 * array.c (rb_ary_dup): reverted r39004. see [Bug #7768], and the
release manager finailly decided to revert it.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-08 10:58:35 +00:00
charliesome 86aa98fed4 * array.c (rb_ary_dup): make returned array the same class as the original
array [Bug #7768] [ruby-core:51792]
* test/ruby/test_array.rb (class TestArray): add test

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-01 14:05:49 +00:00
marcandre 69adf990e1 * array.c (rb_ary_bsearch): Fix r38986 (typo) [Bug #7726]
* range.c (range_bsearch): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-30 06:07:29 +00:00
marcandre a7938af19c * array.c (rb_ary_bsearch): Fix r38986 (missing whitespace)
* range.c (range_bsearch): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-30 06:01:40 +00:00
marcandre 20c0fb69d6 * array.c (rb_ary_bsearch): Raise TypeError on bad return from block
* range.c (range_bsearch): ditto

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

* test/ruby/test_range.rb (class): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-30 06:00:24 +00:00
marcandre 39048aca75 * array.c (rb_ary_bsearch): Return enumerator if no block [#7725]
* range.c (range_bsearch): ditto

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

* test/ruby/test_range.rb: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-30 05:11:03 +00:00
eregon d5b7fc432f * array.c: Improve documentation about
comparison by hash for concerned methods. [ruby-core:51266]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-29 10:32:27 +00:00
marcandre 96af5360a4 * enum.c (enum_zip): Fix error message
* array.c (take_items): Same, for Array#zip
  [Bug #7706]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-24 07:51:05 +00:00
nobu be7bf5aa0c adjust style
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-29 12:22:04 +00:00
ko1 f6f388a5bd * array.c, enum.c, insns.def, io.c, numeric.c, parse.y, process.c,
range.c: use prepared IDs.
  A patch from charliesome (Charlie Somerville).
  [Bug #7495]
* common.mk: add dependency to id.h.
* common.mk: replace ID_H_INCLUDES with id.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-02 09:57:47 +00:00
nobu 66fd9d44d8 adjust style.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-01 15:25:28 +00:00
marcandre 5768a4a7e0 * array.c: Fix rdoc for Array#delete [#7437]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 20:14:49 +00:00
shirosaki 56132b1346 array.c: refactoring of rb_ary_delete_same()
* array.c (ary_resize_smaller): new function to resize array.

* array.c (rb_ary_delete): refactoring to extract a function.

* array.c (rb_ary_delete_same): refactoring.
  It renames function, reduces duplicated code and removes unused
  code.

* gc.c (wmap_final_func): follow the above change.

* internal.h (rb_ary_delete_same): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-25 13:39:26 +00:00
eregon 0012b0abd7 * array.c: fixes for the updated documentation in r35858:
Typos and #take/#drop accept to take/drop 0 elements.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-25 13:28:59 +00:00
shirosaki 1cdeab5cdd Fix WeakRef finalize
* array.c (rb_ary_delete_same_obj): new function for WeakRef.
  This deletes same objects as item argument in the array.

* internal.h (rb_ary_delete_same_obj): add a declaration.

* gc.c (wmap_final_func): remove WeakRef object reference from the
  array. rb_ary_delete() is not usable because it uses rb_equal() to
  compare object references.

* gc.c (wmap_finalize): remove recycled object references from weak
  map hash properly. How to get object reference from object id was
  wrong. st_delete() doesn't work properly if key and value arguments
  are same. The key of obj2wmap is referenced object and the value of
  obj2wmap is WeakRef array.

* gc.c (wmap_aset): obj2wmap should contain WeakRef array in the
  definition.

* test/test_weakref.rb
  (TestWeakRef#test_not_reference_different_object,
   TestWeakRef#test_weakref_finalize): add tests for above.
  [ruby-core:49044] [Bug #7304]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-24 12:26:54 +00:00
shirosaki 005986bd44 Fix Segmentation fault at TestArray#test_aref
* array.c (rb_ary_aref): fix Segmentation fault at TestArray#test_aref
  on x64 mingw. Variable argument of rb_scan_args() should be a pointer
  (VALUE *), but 0 of variable argument seems not equal to null pointer
  on x64 mingw.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-24 04:01:40 +00:00
shirosaki 97ecab7b34 Fix cache validity check of require
* array.c (rb_ary_shared_with_p): fix cache validity check.
  If #pop or #shift has been called against $: or $", the array will
  be still shared with the snapshot. We check array length for cache
  validity.
  [ruby-core:49518] [Bug #7383]

* test/ruby/test_require.rb
  (TestRequire#test_require_with_array_pop,
   TestRequire#test_require_with_array_shift): add tests for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-22 14:55:32 +00:00
marcandre aa58a684b7 * array.c (rb_get_values_at): Improve rdoc
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-20 15:03:52 +00:00
mame 4c37c520e2 * array.c (rb_ary_bsearch): fix rdoc bug (O(n log n) -> O(log n)).
Patch by Charlie Somerville.  [ruby-core:49661] [Bug #7409]

* range.c (range_bsearch): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-20 11:13:45 +00:00
mame 412b023742 * range.c (range_bsearch): fix some bugs: a documentation bug, a wrong
condition, missed break in switch/case, and workaround for GCC
  optimization. See [ruby-core:49364] in detail.  A great patch from
  Heesob Park. [Bug #7352] [Feature #4766]

* array.c (rb_ary_bsearch): fix similar bug (missed break).

* test/ruby/test_range.rb: add two test cases for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-15 13:50:55 +00:00
mame de07850e47 * array.c (rb_ary_bsearch): add Array#bsearch for binary search.
[ruby-core:36390] [Feature #4766]

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

* range.c (range_bsearch): add Range#bsearch for binary search.
  [ruby-core:36390] [Feature #4766]

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

* NEWS: added the two new methods.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-14 15:53:50 +00:00
tenderlove 4c740bae97 * probes.d: add DTrace probe declarations. [ruby-core:27448]
* array.c (empty_ary_alloc, ary_new): added array create DTrace probe.

* compile.c (rb_insns_name): allowing DTrace probes to access
  instruction sequence name.

* Makefile.in: translate probes.d file to appropriate header file.

* common.mk: declare dependencies on the DTrace header.

* configure.in: add a test for existence of DTrace.

* eval.c (setup_exception): add a probe for when an exception is
  raised.

* gc.c: Add DTrace probes for mark begin and end, and sweep begin and
  end.

* hash.c (empty_hash_alloc): Add a probe for hash allocation.

* insns.def: Add probes for function entry and return.

* internal.h: function declaration for compile.c change.

* load.c (rb_f_load): add probes for `load` entry and exit, require
  entry and exit, and wrapping search_required for load path search.

* object.c (rb_obj_alloc): added a probe for general object creation.

* parse.y (yycompile0): added a probe around parse and compile phase.

* string.c (empty_str_alloc, str_new): DTrace probes for string
  allocation.

* test/dtrace/*: tests for DTrace probes.

* vm.c (vm_invoke_proc): add probes for function return on exception
  raise, hash create, and instruction sequence execution.

* vm_core.h: add probe declarations for function entry and exit.

* vm_dump.c: add probes header file.

* vm_eval.c (vm_call0_cfunc, vm_call0_cfunc_with_frame): add probe on
  function entry and return.

* vm_exec.c: expose instruction number to instruction name function.

* vm_insnshelper.c: add function entry and exit probes for cfunc
  methods.

* vm_insnhelper.h: vm usage information is always collected, so
  uncomment the functions.

12 19:14:50 2012  Akinori MUSHA  <knu@iDaemons.org>

* configure.in (isinf, isnan): isinf() and isnan() are macros on
  DragonFly which cannot be found by AC_REPLACE_FUNCS().  This
  workaround enforces the fact that they exist on DragonFly.

12 15:59:38 2012  Shugo Maeda  <shugo@ruby-lang.org>

* vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo),
  vm_insnhelper.c (vm_search_method): revert r37616 because it's too
  slow.  [ruby-dev:46477]

* test/ruby/test_refinement.rb (test_inline_method_cache): skip
  the test until the bug is fixed efficiently.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-12 21:52:12 +00:00
naruse efeee7afa9 * array.c (rb_ary_splice): fix r37583 doesn't condier the case when
beg > array length.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-09 11:04:05 +00:00
nobu fdbd371678 array.c: speedup Array#unshift by using space in shared array
* array.c: speedup Array#unshift by using space in shared array.
  [Feature #6638]
  - when array owns its shared array (ARY_SHARED_NUM == 1), and there
    is enough space then try unshift values directly into shared
    array.
  - when resulting array is big (~>64 items) then make it shared with
    enough room for future #unshifts, and then insert into shared
    array.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-09 07:08:50 +00:00
nobu aaa9cb1ab4 array.c: use shared array in rb_ary_slice
* array.c (rb_ary_splice): use shared array in rb_ary_slice.
  [Feature #6638]
  - use ary_ensure_room_for_push when rb_ary_slice used to add at the
    end of array, cause rb_ary_concat use rb_ary_slice.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-09 07:08:45 +00:00
nobu b11975dfe0 array.c: make array really suitable for queue
* array.c (ary_ensure_room_for_push): make array really suitable for
  queue.  [Feature #6638]
  when array is shared (which happens after Array#shift), and
  ARY_SHARED_NUM == 1 (which is very often when array used as queue),
  then make rb_ary_push push directly into shared array.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-09 07:08:42 +00:00
nobu 06de286c68 array.c: steal shared array's container when ARY_SHARED_NUM == 1
* array.c (rb_ary_modify): steal shared array's container when
  ARY_SHARED_NUM == 1.  [Feature #6638]
  - Do not allocate new memory in rb_ary_modify when ARY_SHARED_NUM == 1
    and length almost same.
  - Store ARY_CAPA instead of RARRAY_LEN in ary_make_shared, to make
    it useful.
  - Fix rb_ary_sort_bang accordantly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-09 07:08:38 +00:00
marcandre bc63449331 * array.c: Fix mistake in rdoc of Array#uniq.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-07 19:45:59 +00:00
marcandre b8b01ab995 * array.c (rb_ary_cycle): Support for Array#cycle.size
[Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:12:05 +00:00
marcandre ba59365db9 * array.c (rb_ary_repeated_combination): Support for repeated_combination.size
[Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:11:51 +00:00
marcandre 68c90c4a2d * array.c (rb_ary_repeated_permutation): Support for repeated_permutation.size
[Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:11:36 +00:00
marcandre 6bbf668d6e * array.c (rb_ary_combination): Support for Array#combination.size
[Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37502 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:11:21 +00:00
marcandre 1cb9f27c13 * array.c (rb_ary_permutation): Support for Array#permutation.size
[Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:11:06 +00:00
marcandre 55fb13eff9 * array.c: Support for Enumerator#size in trivial cases:
each, each_index, reverse_each, sort_by, collect,
  collect!, select, select!, keep_if, reject, reject!, delete_if
  [Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:10:50 +00:00
shirosaki e575070f2f Expose whether two arrays are shared
* array.c (rb_ary_shared_with_p): new function.
  Expose whether two arrays are shared (read-only, C only).

* include/ruby/intern.h (rb_ary_shared_with_p): declare.
  Patch by Greg Price.
  [ruby-core:47970] [Bug #7158]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-05 15:24:07 +00:00
glass a28a060db4 * array.c (recursive_equal): fix to return true when self and other
are resized to same size and the current index become out of
  range.

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37464 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-04 02:44:58 +00:00
glass c032c5bc9a * array.c (recursive_equal): fix not to make invalid pointers when
self and other are resized to same size in #== of their elements.
  [ruby-dev:46373] [Feature #6177]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-03 03:21:47 +00:00
glass da9f6cdcb7 * array.c (recursive_equal): performance improvement.
[ruby-dev:45412] [Feature #6177]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-02 07:04:39 +00:00
nari c3a46d6aca * include/ruby/ruby.h: add C APIs.
VALUE rb_newobj_of(VALUE klass, VALUE flags)
  #define NEWOBJ_OF(obj,type,klass,flags)
  These allow to change a allocation strategy depending on klass
  or flags.

* gc.c: ditto

* array.c: use new C API.
* bignum.c: ditto
* class.c: ditto
* complex.c: ditto
* ext/socket/ancdata.c: ditto
* ext/socket/option.c: ditto
* hash.c: ditto
* io.c: ditto
* marshal.c: ditto
* numeric.c: ditto
* object.c: ditto
* random.c: ditto
* range.c: ditto
* rational.c: ditto
* re.c: ditto
* string.c: ditto
* struct.c: ditto
  [Feature #7177][Feature #7047]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-20 06:57:51 +00:00
nobu e3efce6df1 array.c: use rb_random_ulong_limited
* array.c (rb_ary_sample): use rb_random_ulong_limited, since
  precision of long may be larger than double.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-09 09:01:40 +00:00
nobu 2b64e10feb remove garbages.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-20 07:06:06 +00:00
nobu abeedb0875 array.c, enum.c: TypeError in zip
* array.c (take_items), enum.c (enum_zip): raise TypeError at
  non-enumerable objects, not NoMethodError.  [ruby-dev:46145]
  [Bug #7038]
* vm_eval.c (rb_check_block_call): check_funcall variant with block
  function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-19 15:42:26 +00:00
zzak 00fb59f19a * array.c (rb_ary_diff, rb_ary_uniq):
Enhance documentation for array uniqueness
  Based on a patch by Robin Dupret
  [Bug #6872] [ruby-core:47209]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-13 19:08:45 +00:00