mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 21:49:06 +02:00
* st.c (st_foreach_check): chnage start point of search at check from top to current. [ruby-dev:48047] [Bug #9646] * st.c (st_foreach_check): change start point of search at check git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d2d9d6ef17
commit
a383ffa07b
4 changed files with 28 additions and 6 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Mon Jul 7 12:57:26 2014 Masaya Tarui <tarui@ruby-lang.org>
|
||||||
|
|
||||||
|
* st.c (st_foreach_check): change start point of search at check
|
||||||
|
from top to current. [ruby-dev:48047] [Bug #9646]
|
||||||
|
|
||||||
Mon Jul 7 12:53:45 2014 Zachary Scott <e@zzak.io>
|
Mon Jul 7 12:53:45 2014 Zachary Scott <e@zzak.io>
|
||||||
|
|
||||||
* lib/gserver.rb: [DOC] Fixed typo in example by @stomar [Bug #9543]
|
* lib/gserver.rb: [DOC] Fixed typo in example by @stomar [Bug #9543]
|
||||||
|
|
16
st.c
16
st.c
|
@ -393,9 +393,8 @@ find_entry(st_table *table, st_data_t key, st_index_t hash_val, st_index_t bin_p
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline st_index_t
|
static inline st_index_t
|
||||||
find_packed_index(st_table *table, st_index_t hash_val, st_data_t key)
|
find_packed_index_from(st_table *table, st_index_t hash_val, st_data_t key, st_index_t i)
|
||||||
{
|
{
|
||||||
st_index_t i = 0;
|
|
||||||
while (i < table->real_entries &&
|
while (i < table->real_entries &&
|
||||||
(PHASH(table, i) != hash_val || !EQUAL(table, key, PKEY(table, i)))) {
|
(PHASH(table, i) != hash_val || !EQUAL(table, key, PKEY(table, i)))) {
|
||||||
i++;
|
i++;
|
||||||
|
@ -403,6 +402,12 @@ find_packed_index(st_table *table, st_index_t hash_val, st_data_t key)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline st_index_t
|
||||||
|
find_packed_index(st_table *table, st_index_t hash_val, st_data_t key)
|
||||||
|
{
|
||||||
|
return find_packed_index_from(table, hash_val, key, 0);
|
||||||
|
}
|
||||||
|
|
||||||
#define collision_check 0
|
#define collision_check 0
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -934,9 +939,10 @@ st_foreach_check(st_table *table, int (*func)(ANYARGS), st_data_t arg, st_data_t
|
||||||
if (PHASH(table, i) == 0 && PKEY(table, i) == never) {
|
if (PHASH(table, i) == 0 && PKEY(table, i) == never) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i = find_packed_index(table, hash, key);
|
i = find_packed_index_from(table, hash, key, i);
|
||||||
if (i == table->real_entries) {
|
if (i >= table->real_entries) {
|
||||||
goto deleted;
|
i = find_packed_index(table, hash, key);
|
||||||
|
if (i >= table->real_entries) goto deleted;
|
||||||
}
|
}
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case ST_CONTINUE:
|
case ST_CONTINUE:
|
||||||
|
|
|
@ -951,6 +951,17 @@ class TestHash < Test::Unit::TestCase
|
||||||
assert_predicate(h.dup, :compare_by_identity?, bug8703)
|
assert_predicate(h.dup, :compare_by_identity?, bug8703)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_same_key
|
||||||
|
bug9646 = '[ruby-dev:48047] [Bug #9646] Infinite loop at Hash#each'
|
||||||
|
h = @cls[a=[], 1]
|
||||||
|
a << 1
|
||||||
|
h[[]] = 2
|
||||||
|
a.clear
|
||||||
|
cnt = 0
|
||||||
|
r = h.each{ break nil if (cnt+=1) > 100 }
|
||||||
|
assert_not_nil(r,bug9646)
|
||||||
|
end
|
||||||
|
|
||||||
class ObjWithHash
|
class ObjWithHash
|
||||||
def initialize(value, hash)
|
def initialize(value, hash)
|
||||||
@value = value
|
@value = value
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#define RUBY_VERSION "2.0.0"
|
#define RUBY_VERSION "2.0.0"
|
||||||
#define RUBY_RELEASE_DATE "2014-07-07"
|
#define RUBY_RELEASE_DATE "2014-07-07"
|
||||||
#define RUBY_PATCHLEVEL 529
|
#define RUBY_PATCHLEVEL 530
|
||||||
|
|
||||||
#define RUBY_RELEASE_YEAR 2014
|
#define RUBY_RELEASE_YEAR 2014
|
||||||
#define RUBY_RELEASE_MONTH 7
|
#define RUBY_RELEASE_MONTH 7
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue