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

671 Коммитов

Автор SHA1 Сообщение Дата
glass 806b93ed9b * array.c (rb_ary_uniq_bang): use st_foreach() instead of for loop.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43467 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29 13:14:19 +00:00
marcandre dc215dcd9f * array.c: Add Array#to_h [Feature #7292]
* enum.c: Add Enumerable#to_h

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-23 15:10:48 +00:00
ko1 76b06555d0 * gc.c, internal.h: rename ruby_xsizefree/realloc to
rb_sized_free/realloc.
* array.c: catch up these changes.
* string.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-17 08:41:23 +00:00
ko1 3de7ec0a3f * array.c, string.c: use ruby_xsizedfree() and ruby_xsizedrealloc().
* internal.h (SIZED_REALLOC_N): define a macro as REALLOC_N().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-17 08:35:06 +00:00
nobu 4a01df4a04 array.c: reduce RARRAY_LEN and ARY_CAPA
* array.c: reduce use of RARRAY_LEN and ARY_CAPA when object is not
  modified.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43291 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-15 07:34:05 +00:00
glass d4f37a5532 * array.c (rb_ary_or): remove unused variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43241 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-10 14:04:55 +00:00
glass 2423e3f350 * array.c (rb_ary_or): use rb_hash_keys().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43240 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-10 14:02:52 +00:00
glass 840cd22d85 * array.c (rb_ary_compact_bang): use ary_resize_smaller().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-10 12:37:58 +00:00
nobu 9c6ea2f200 array.c: use rb_hash_values
* array.c (rb_ary_uniq): use rb_hash_values(), as well as the case no
  block is given.
* internal.h: define rb_hash_values() as internal API.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-08 07:11:15 +00:00
nobu 827f4d653b array.c: set class
* array.c (rb_ary_uniq): set class of the return value to the receiver
  class.  fix failure in TestArray#test_array_subclass.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-08 06:35:29 +00:00
nobu 5014840140 array.c: remove unused variables
* array.c (rb_ary_uniq): remove no longer used local variables since
  r43194.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-08 05:19:57 +00:00
glass 41eb48b88d * array.c (rb_ary_uniq): use rb_hash_keys().
* internal.h: define rb_hash_keys() as internal API.

* hash.c (rb_hash_keys): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-08 04:56:50 +00:00
nobu 92b0e5b2ec array.c: minor performance improvement
* array.c (sort_2): minor performance improvement by replacing
  rb_funcall() with rb_funcallv.

* array.c (rb_ary_bsearch, recursive_cmp, rb_ary_cycle_size): ditto.

* array.c (descending_factorial, binomial_coefficient): ditto.

* array.c (rb_ary_repeated_permutation_size): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-29 14:51:03 +00:00
ko1 dc626dbab3 * include/ruby/ruby.h: rename RARRAY_RAWPTR() to RARRAY_CONST_PTR().
RARRAY_RAWPTR(ary) returns (const VALUE *) type pointer and
  usecase of this macro is not acquire raw pointer, but acquire
  read-only pointer. So we rename to better name.
  RSTRUCT_RAWPTR() is also renamed to RSTRUCT_CONST_PTR()
  (I expect that nobody use it).
* array.c, compile.c, cont.c, enumerator.c, gc.c, proc.c, random.c,
  string.c, struct.c, thread.c, vm_eval.c, vm_insnhelper.c:
  catch up this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-25 08:24:34 +00:00
nobu f25daa2541 array.c: optimized equality
* array.c (rb_ary_index, rb_ary_rindex): use optimized equality to
  improve performance.  [Feature #8820]
* vm_insnhelper.c (rb_equal_opt): optimized equality function.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-27 07:46:08 +00:00
nobu c075b153e8 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42689 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-26 06:02:47 +00:00
ko1 ad0ef29da7 * array.c (rb_ary_splice): use RARRAY_PTR_USE() without WB because
there are not new relations.
* enum.c (enum_sort_by): ditto.
* struct.c (setup_struct): use RARRAY_RAWPTR().
* vm_eval.c (yield_under): ditto.
* ext/pathname/pathname.c (path_entries): use RARRAY_AREF().
* ext/pathname/pathname.c (path_s_glob): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-26 05:47:27 +00:00
kazu e86d9fe858 * array.c (ary_ensure_room_for_push): fix typo in r42658.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-26 04:13:46 +00:00
ko1 5bcdc68c6e * array.c (ary_make_shared): shared ary as shady. Need more effort to
make it normal object.
* array.c (rb_ary_modify): use RARRAY_PTR_USE() without WB because
  there are not new relations.
* array.c (ary_ensure_room_for_unshift): use RARRAY_RAWPTR() because
  there are not new relations.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-23 09:42:18 +00:00
ko1 c50d45fc96 * array.c: introduce ARY_SHARED_OCCUPIED(shared).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-23 02:27:32 +00:00
glass 07e3b30c84 * array.c (rb_ary_zip): performance implement by using
ALLOCA_N() to allocate tmp buffer.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-04 12:24:26 +00:00
glass 633fd55c4c * array.c (rb_ary_zip): use rb_ary_new2() to create buffer
if rb_block_arity() > 1.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-02 15:36:20 +00:00
glass 5339293fb8 * array.c (rb_ary_zip): performance improvement by avoiding
array creation if rb_block_arity() > 1.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-02 14:56:39 +00:00
ko1 d462261395 * array.c (ary_memcpy): cast to int to suppress a warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-26 09:31:17 +00:00
ko1 d320b2d9e9 * array.c (ary_memcpy): try to enable optimization.
At least on my environments, I don't see any errors
  with many trials. Please tell us if you find any GC bugs.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-26 09:23:40 +00:00
ko1 33ebcb0538 * array.c, gc.c: move ary_unprotect_logging() into
rb_gc_unprotect_logging() which is general version
* include/ruby/ruby.h: add USE_RGENGC_LOGGING_WB_UNPROTECT
  to enable.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-24 09:42:43 +00:00
ko1 8160fab8bc * array.c (ary_resize_capa): use RARRAY_RAWPTR() because
this code creates no new references.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42106 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-22 04:21:01 +00:00
ko1 8eb0a3cd50 * array.c (ary_memfill): added.
* array.c (rb_ary_initialize): use ary_memfill().
* array.c (rb_ary_fill): ditto.
* array.c (rb_ary_slice_bang): use RARRAY_RAWPTR() because
  this code creates no new references.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-22 04:00:12 +00:00
ko1 3a20287053 * array.c (rb_ary_resize): use simple memcpy because there are no new
references.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-20 06:24:11 +00:00
ko1 45e8268d62 * array.c (ary_make_shared): make shared array shady.
Making non-shady shared array causes SEGV (see rubyci).
  It seems a bug around shared array.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-20 05:39:57 +00:00
ko1 6e3c4fd8b5 * array.c: reduce shady operations.
* array.c (rb_ary_modify, ary_make_partial, rb_ary_splice,
  rb_ary_replace, rb_ary_eql, rb_ary_compact_bang):
  use RARRAY_RAWPTR() instead of RARRAY_PTR().
* array.c (rb_ary_shift): use RARRAY_PTR_USE() without WB because
  there are not new relations.
* array.c (ary_ensure_room_for_unshift): ditto.
* array.c (rb_ary_sort_bang): ditto.
* array.c (rb_ary_delete_at): ditto.
* array.c (rb_ary_reverse_m): use RARRAY_RAWPTR() because
  there are not new relations.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-19 12:56:58 +00:00
ko1 8d8ead142c * array.c: reduce shade operations.
* array.c (rb_ary_modify): use RARRAY_RAWPTR().
* array.c (ary_make_substitution, rb_ary_s_create, ary_make_partial,
  rb_ary_splice, rb_ary_resize, rb_ary_rotate_m, rb_ary_times):
  use ary_memcpy().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-19 12:12:31 +00:00
ko1 9cc7f5f829 * array.c (ary_mem_clear): added. This operation doesn't need WB
because this operation creates a reference to Qnil.
* array.c (ary_make_shared, rb_ary_store, rb_ary_shift_m,
  rb_ary_splice, rb_ary_resize, rb_ary_fill): use ary_mem_clear()
  instead of rb_mem_clear().
* array.c (ary_make_shared): use RARRAY_RAWPTR() instead of RARRAY_PTR().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42070 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-19 11:08:13 +00:00
ko1 a6e1e3d637 * array.c: fix commit miss.
RGENGC_UNPROTECT_LOGGING should be 0.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-19 10:19:19 +00:00
ko1 5ef247aa60 * array.c (rb_ary_resurrect): use RARRAY_RAWPTR() because there is no
writing.
* array.c (rb_ary_new_from_values): use ary_memcpy().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42066 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-19 10:16:31 +00:00
ko1 01bf495286 * array.c (ary_memcpy): add a function to copy VALUEs into ary
with write barrier. If ary is promoted, use write barrier correctly.
* array.c (rb_ary_cat, rb_ary_unshift_m, rb_ary_dup,
  rb_ary_sort_bang, rb_ary_replace, rb_ary_plus): use ary_memcpy().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42065 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-19 10:10:31 +00:00
ko1 77887cf01c * array.c (rb_ary_store): use RARRAY_PTR_USE() intead of RARRAY_PTR().
Clearing memory space doesn't need WBs.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-19 06:34:18 +00:00
ko1 b9b5a2ccab * array.c (ary_ensure_room_for_push): use RARRAY_RAWPTR() instead of
RARRAY_PTR. In this code, there are no "write" operation.
* array.c (rb_ary_equal): ditto.
* array.c (recursive_equal): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-19 06:21:12 +00:00
ko1 8e5374d05a * array.c (ary_unprotect_logging): use (void *) for first parameter
because VALUE is not defined before including ruby/ruby.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-19 06:00:28 +00:00
glass 2de786d437 * array.c (rb_ary_eql): compare RARRAY_PTR() for performance
improvement in case of that self and other are shared.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-18 14:47:27 +00:00
glass 4595d9a3c9 * array.c (rb_ary_equal): compare RARRAY_PTR() for performance
improvement in case of that self and other are shared.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-18 12:21:51 +00:00
glass e07e814ec3 * array.c (rb_ary_fill): use memfill().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-18 11:51:54 +00:00
eregon e1335a307c * array.c (rb_ary_count): check length to avoid SEGV
while iterating. Remove other pointer loop when arg is given.
* test/ruby/test_array.rb (test_count): add test for bug.
  [ruby-core:56072] [Bug #8654]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-18 11:38:01 +00:00
glass 6f49bc635b * hash.c (rb_hash_flatten): performance improvement by not using
rb_hash_to_a() to avoid array creation with rb_assoc_new().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-18 09:18:50 +00:00
ko1 faa9d5eced * array.c: add logging feature for RGenGC's write barrier unprotect
event.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-18 07:18:22 +00:00
ko1 6429bbad59 * array.c (ary_alloc): slim setup process.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-18 05:54:32 +00:00
nobu 3569c6c3a6 array.c: fix typo
* array.c (rb_ary_count): [DOC] fix typo.  Array#count uses ==, not
  ===.  a question at asakusa.rb ML.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16 09:50:11 +00:00
zzak be698dbc66 * array.c: Replace confusing example for #reverse_each in overview
Patch by Earl St Sauver [Fixes documenting-ruby/ruby-12]
  https://github.com/documenting-ruby/ruby/pull/12


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41917 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-11 05:51:19 +00:00
nobu 5e2f227d21 intern.h: define rb_enumerator_size_func
* include/ruby/intern.h (rb_enumerator_size_func): define strict
  function declaration for rb_enumeratorize_with_size().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-26 13:43:22 +00:00
zzak 6e088d299c * array.c: Return value in Array overview example found by @PragTob
[Fix GH-336] https://github.com/ruby/ruby/pull/336


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-23 17:55:15 +00:00
zzak 10d5f123d9 * array.c (rb_ary_zip): typo by @PragTob [Fix GH-337]
https://github.com/ruby/ruby/pull/337


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-23 17:46:50 +00:00
ko1 508b255b9a * include/ruby/ruby.h: constify RArray::as::ary and RArray::heap::ptr.
Use RARRAY_ASET() or RARRAY_PTR_USE() to modify Array objects.
* array.c, gc.c: catch up above changes.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 11:53:33 +00:00
shugo 1f828497d1 * safe.c (rb_set_safe_level, safe_setter): raise an ArgumentError
when $SAFE is set to 4.  $SAFE=4 is now obsolete.
  [ruby-core:55222] [Feature #8468]

* object.c (rb_obj_untrusted, rb_obj_untrust, rb_obj_trust):
  Kernel#untrusted?, untrust, and trust are now deprecated.
  Their behavior is same as tainted?, taint, and untaint,
  respectively.

* include/ruby/ruby.h (OBJ_UNTRUSTED, OBJ_UNTRUST): OBJ_UNTRUSTED()
  and OBJ_UNTRUST() are aliases of OBJ_TAINTED() and OBJ_TAINT(),
  respectively.

* array.c, class.c, debug.c, dir.c, encoding.c, error.c, eval.c,
  ext/curses/curses.c, ext/dbm/dbm.c, ext/dl/cfunc.c,
  ext/dl/cptr.c, ext/dl/dl.c, ext/etc/etc.c, ext/fiddle/fiddle.c,
  ext/fiddle/pointer.c, ext/gdbm/gdbm.c, ext/readline/readline.c,
  ext/sdbm/init.c, ext/socket/ancdata.c, ext/socket/basicsocket.c,
  ext/socket/socket.c, ext/socket/udpsocket.c,
  ext/stringio/stringio.c, ext/syslog/syslog.c, ext/tk/tcltklib.c,
  ext/win32ole/win32ole.c, file.c, gc.c, hash.c, io.c, iseq.c,
  load.c, marshal.c, object.c, proc.c, process.c, random.c, re.c,
  safe.c, string.c, thread.c, transcode.c, variable.c,
  vm_insnhelper.c, vm_method.c, vm_trace.c: remove code for
  $SAFE=4.

* test/dl/test_dl2.rb, test/erb/test_erb.rb,
  test/readline/test_readline.rb,
  test/readline/test_readline_history.rb, test/ruby/test_alias.rb,
  test/ruby/test_array.rb, test/ruby/test_dir.rb,
  test/ruby/test_encoding.rb, test/ruby/test_env.rb,
  test/ruby/test_eval.rb, test/ruby/test_exception.rb,
  test/ruby/test_file_exhaustive.rb, test/ruby/test_hash.rb,
  test/ruby/test_io.rb, test/ruby/test_method.rb,
  test/ruby/test_module.rb, test/ruby/test_object.rb,
  test/ruby/test_pack.rb, test/ruby/test_rand.rb,
  test/ruby/test_regexp.rb, test/ruby/test_settracefunc.rb,
  test/ruby/test_struct.rb, test/ruby/test_thread.rb,
  test/ruby/test_time.rb: remove tests for $SAFE=4.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12 14:20:51 +00:00
nobu 221496de7c array.c: fix false assertions
* array.c (rb_ary_sort_bang): remove duplicated assertions.
  ARY_HEAP_PTR() implies ary not to be embedded.  [ruby-dev:47419]
  [Bug #8518]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12 07:41:40 +00:00
nobu 7fa5e608d3 array.c: freeze in callback
* array.c (rb_ary_uniq_bang): must not be modified once frozen even in
  a callback method.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12 03:04:11 +00:00
nobu da786437a7 array.c: freeze in callback
* array.c (rb_ary_sort_bang): must not be modified once frozen even in
  a callback method.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41246 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12 03:03:46 +00:00
nobu ff7bb4723b array.c: fix false assertion
* array.c (FL_SET_EMBED): shared object is frozen even when get
  unshared.
* array.c (rb_ary_modify): ARY_SET_CAPA needs unshared array.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41245 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12 03:00:24 +00:00
nobu 6ff25d132d array.c: assertion
* array.c (ary_shrink_capa): additional assertion.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12 03:00:17 +00:00
nobu c5c201f624 array.c: fix false assertion in ary_make_shared
* array.c (ary_shrink_capa): shrink the capacity so it fits just with
  the length.
* array.c (ary_make_shared): release never used elements from frozen
  array to be shared.  [ruby-dev:47416] [Bug #8510]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-11 07:15:24 +00:00
kazu 0ab44dbc3c fix a typo
* array.c (rb_ary_new_from_values): fix a typo. pointed out by nagachika.
  http://d.hatena.ne.jp/nagachika/20130610/ruby_trunk_changes_41199_41220

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-10 14:54:21 +00:00
ko1 f8ba9a1f60 * array.c (rb_ary_new_from_values): add assertion
(ary should be young object).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-10 07:23:36 +00:00
akr bd15d4ca78 * internal.h (numberof): Gathered from various files.
* array.c, math.c, thread_pthread.c, iseq.c, enum.c, string.c, io.c,
  load.c, compile.c, struct.c, eval.c, gc.c, parse.y, process.c,
  error.c, ruby.c: Remove the definitions of numberof.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 10:01:19 +00:00
nobu 83db393e48 adjust style
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 02:52:42 +00:00
tarui 7185eac56a * array.c (ary_new): change order of allocation in order
to remove FL_OLDGEN operation.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41124 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 02:20:05 +00:00
eregon ed318080ad * array.c (Array#+): fix documentation example.
Patch by Logan Serman. [Fixes GH-324]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-04 16:16:36 +00:00
nobu 1c5cdc62cc array.c: new names of rb_ary_new family
* array.c (rb_ary_new_capa): add better names of rb_ary_new2.
* array.c (rb_ary_new_from_args): ditto for rb_ary_new3.
* array.c (rb_ary_new_from_values): ditto for rb_ary_new4.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-31 08:04:56 +00:00
ko1 c4c821a7d7 * hash.c (rb_hash_tbl_raw), internal.h: added.
Returns st_table without shading hash.
* array.c: use rb_hash_tbl_raw() for read-only purpose.
* compile.c (iseq_compile_each): ditto.
* gc.c (count_objects): ditto.
* insns.def: ditto.
* process.c: ditto.
* thread.c (clear_coverage): ditto.
* vm_insnhelper.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-26 16:19:04 +00:00
ko1 4f401816ff * gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
  check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
  you want to access raw pointers. If you modify the contents which
  pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
  and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
  barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
  generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
  FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
  move flag bits.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
ko1 83aba04862 * include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'.
  This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
  This function reveal interal (hidden) object by rb_obj_hide().
  Note that do not change class before and after hiding.
  Only permitted example is:
  klass = RBASIC_CLASS(obj);
  rb_obj_hide(obj);
  ....
  rb_obj_reveal(obj, klass);
  TODO: API design. rb_obj_reveal() should be replaced with others.
  TODO: modify constified variables using cast may be harmful for
  compiler's analysis and optimizaton.
  Any idea to prohibt inserting RBasic::klass directly?
  If rename RBasic::klass and force to use RBASIC_CLASS(obj),
  then all codes such as `RBASIC(obj)->klass' will be
  compilation error. Is it acceptable? (We have similar
  experience at Ruby 1.9,
  for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
  object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
  without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
  file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
  parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
  string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
  Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
  ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 10:49:11 +00:00
ko1 aacd771046 * *.c, parse.y, insns.def: use RARRAY_AREF/ASET macro
instead of using RARRAY_PTR().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 09:56:22 +00:00
marcandre 017f0ffe18 * array.c: Improve rdoc for eql?
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-24 22:12:31 +00:00
zzak 00ecebe6a9 * array.c: Fix documentation for Array#index and #replace aliases
Based on a patch by @phiggins [Fixes GH-282]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-24 03:28:06 +00:00
hsbt e9b63c1a22 enhanced Array#delete_if docs by johnnymugs
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-22 09:35:27 +00:00
marcandre 6e41c7c559 * array.c: rdoc tweak for include?
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-13 04:31:15 +00:00
zzak 9ef4e13459 * array.c: Document synonymous methods, by windwiny [GH-277]
* bignum.c: ditto
* complex.c: ditto
* dir.c: ditto
* encoding.c: ditto
* enumerator.c: ditto
* numeric.c: ditto
* proc.c: ditto
* re.c: ditto
* string.c: ditto


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-12 02:59:07 +00:00
akr 712c7168bf * internal.h (MUL_OVERFLOW_SIGNED_INTEGER_P): New macro.
(MUL_OVERFLOW_FIXNUM_P): Ditto.
  (MUL_OVERFLOW_LONG_P): Ditto.

* array.c (rb_ary_product): Don't overflow on signed integer
  multiplication.

* numeric.c (fix_mul): Ditto.
  (int_pow): Ditto.

* rational.c (f_imul): Ditto.

* insns.def (opt_mult): Ditto.

* thread.c (sleep_timeval): Don't overflow on signed integer addition.

* bignum.c (rb_int2big): Don't overflow on signed integer negation.
  (rb_big2ulong): Ditto.
  (rb_big2long): Ditto.
  (rb_big2ull): Ditto.
  (rb_big2ll): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-09 11:39:53 +00:00
nobu fd7dc1b6ea reduce overhead of TYPE
* array.c (ary_join_1): reduce overhead of TYPE().

* eval.c (rb_frozen_class_p, rb_mod_{append,prepend}_features): ditto.

* string.c (rb_to_id): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-04 08:23:10 +00:00
nobu b79ba4a745 * array.c (take_items): honor encoding of class name.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-23 08:45:32 +00:00
nobu 04c9bdb190 vm_eval.c: preserve passed_block
* vm_eval.c (check_funcall_respond_to): preserve passed_block, which
  is modified in vm_call0_body() via vm_call0(), and caused a bug of
  rb_check_funcall() by false negative result of rb_block_given_p().
  re-fix [ruby-core:53650] [Bug #8153].
  [ruby-core:53653] [Bug #8154]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-23 08:39:55 +00:00
marcandre cb0093d545 * array.c: Avoid zip bug by not using obsolete rb_check_block_call [Bug #8153]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-22 22:30:45 +00:00
zzak d883d756d1 * array.c: Typo in Array#delete by Timo Sand [GH fixes #258]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-17 18:19:56 +00:00
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