зеркало из https://github.com/github/ruby.git
Remove dead code in ar_copy
All of the callers of ar_copy guarantee that hash2 has an ar table, so we don't need the logic to handle the case when hash2 doesn't have an ar table.
This commit is contained in:
Родитель
f901b934fd
Коммит
e30cf60a19
22
hash.c
22
hash.c
|
@ -1199,9 +1199,8 @@ static ar_table*
|
|||
ar_copy(VALUE hash1, VALUE hash2)
|
||||
{
|
||||
ar_table *old_tab = RHASH_AR_TABLE(hash2);
|
||||
|
||||
if (old_tab != NULL) {
|
||||
ar_table *new_tab = RHASH_AR_TABLE(hash1);
|
||||
|
||||
if (new_tab == NULL) {
|
||||
new_tab = (ar_table*) rb_transient_heap_alloc(hash1, sizeof(ar_table));
|
||||
if (new_tab != NULL) {
|
||||
|
@ -1212,6 +1211,7 @@ ar_copy(VALUE hash1, VALUE hash2)
|
|||
new_tab = (ar_table*)ruby_xmalloc(sizeof(ar_table));
|
||||
}
|
||||
}
|
||||
|
||||
*new_tab = *old_tab;
|
||||
RHASH(hash1)->ar_hint.word = RHASH(hash2)->ar_hint.word;
|
||||
RHASH_AR_TABLE_BOUND_SET(hash1, RHASH_AR_TABLE_BOUND(hash2));
|
||||
|
@ -1219,24 +1219,8 @@ ar_copy(VALUE hash1, VALUE hash2)
|
|||
hash_ar_table_set(hash1, new_tab);
|
||||
|
||||
rb_gc_writebarrier_remember(hash1);
|
||||
|
||||
return new_tab;
|
||||
}
|
||||
else {
|
||||
RHASH_AR_TABLE_BOUND_SET(hash1, RHASH_AR_TABLE_BOUND(hash2));
|
||||
RHASH_AR_TABLE_SIZE_SET(hash1, RHASH_AR_TABLE_SIZE(hash2));
|
||||
|
||||
if (RHASH_TRANSIENT_P(hash1)) {
|
||||
RHASH_UNSET_TRANSIENT_FLAG(hash1);
|
||||
}
|
||||
else if (RHASH_AR_TABLE(hash1)) {
|
||||
ruby_xfree(RHASH_AR_TABLE(hash1));
|
||||
}
|
||||
|
||||
hash_ar_table_set(hash1, NULL);
|
||||
|
||||
rb_gc_writebarrier_remember(hash1);
|
||||
return old_tab;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Загрузка…
Ссылка в новой задаче