* hash.c (rb_hash_keys): use st_keys() for performance improvement
if st_data_t and VALUE are compatible.
* st.h: define macro ST_DATA_COMPATIBLE_P() to predicate whether
st_data_t and passed type are compatible.
* configure.in: check existence of builtin function to use in
ST_DATA_COMPATIBLE_P().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
keys. Patch by Eric Wong. [Bug #8998] [ruby-core:57727]
* test/ruby/test_hash.rb (class TestHash): test for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c (rb_hash): cut off if recursion detected to get rid of stack
overflow. [ruby-core:58567] [Bug #9151]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c (NOINSERT_UPDATE_CALLBACK): make both of noinsert and insert
internal functions static. and put semicolons for etags to find the
following functions properly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (ruby_register_rollback_func_for_ensure): catch up above change.
Add rollback mechanism API.
* vm_core.h (typedef struct rb_vm_struct): catch up above change.
Introdule ensure-rollback relation table.
* vm_core.h (typedef struct rb_thread_struct): catch up above change.
Introdule ensure stack.
* eval.c (rb_ensure): catch up above change.
Introdule ensure stack.
* hash.c : New function for rollback ensure, and register it to
ensure-rollback relation table. [ruby-dev:47803] [Bug #9105]
Ensure Rollback Mechanism:
A rollback's function is a function to rollback a state before ensure's
function execution.
When the jump of callcc is across the scope of rb_ensure,
ensure's functions and rollback's functions are executed appropriately
for keeping consistency.
Current API is unstable, and only internal use.
ruby_register_rollback_func_for_ensure(ensure_func,rollback_func)
This API create relation ensure's function to rollback's function.
By registered rollback's function, it is executed When jumpping into
corresponding rb_ensure scope.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c (hash_foreach_iter, hash_foreach_ensure, rb_hash_foreach):
deal with iteration level when reentering by callcc. temporary
measure until rollback of ensure is introduced. [ruby-dev:47807]
[Bug #9105]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c (hash_foreach_ensure): restore iter_lev to the previous
value, not just decrement. [ruby-dev:47803] [Bug #9105]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c (foreach_safe_i, hash_foreach_iter): deal with error detected
by ST_CHECK.
* st.c (st_foreach_check): call with non-error argument in normal case.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c: revert st_keys() at r43238. VALUE cannot be in st.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* 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
compare function in RHASH(hash)->ntbl->type temporarily like r42224.
it falls back to rb_hash_foreach() if st_lookup() doesn't find the key.
* test/ruby/test_hash.rb: add a test for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
called only if hashes are matched.
* test/ruby/test_hash.rb: add a test to check using #== to compare.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
rb_hash_to_a() to avoid array creation with rb_assoc_new().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c (env_fetch): Add key name to message on ENV.fetch KeyError,
as well as Hash#fetch. [ruby-core:56062] [Feature #8649]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
parameter `slot'. You don't need to write a cast (VALUE *) any more.
* class.c, compile.c, hash.c, iseq.c, proc.c, re.c, variable.c,
vm.c, vm_method.c: remove cast expressions for OBJ_WRITE().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c (ruby_setenv): refine error message so include the variable
name.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
write barriers at callback function are too early.
All write barriers are executed after `st_update()'
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
flag if numwords is 1 or less.
(absint_numwords_generic): Don't specify a word order for
rb_integer_pack.
* hash.c (rb_hash): Ditto.
* time.c (v2w_bignum): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e