Skip to content

Commit

Permalink
constify RHash::ifnone.
Browse files Browse the repository at this point in the history
RHash::ifnone should be protected by write-barriers so this field
should be const. However, to introduce GC.compact, the const was
removed. This commit revert this removing `const` and modify
gc.c `TYPED_UPDATE_IF_MOVED` to remove `const` forcely by a type cast.
  • Loading branch information
ko1 committed Jul 22, 2019
1 parent d1c2b19 commit f75561b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gc.c
Expand Up @@ -915,7 +915,7 @@ static inline void gc_prof_set_heap_info(rb_objspace_t *);

#define TYPED_UPDATE_IF_MOVED(_objspace, _type, _thing) do { \
if (gc_object_moved_p(_objspace, (VALUE)_thing)) { \
(_thing) = (_type)RMOVED((_thing))->destination; \
*((_type *)(&_thing)) = (_type)RMOVED((_thing))->destination; \
} \
} while (0)

Expand Down
2 changes: 1 addition & 1 deletion internal.h
Expand Up @@ -873,7 +873,7 @@ struct RHash {
struct ar_table_struct *ar; /* possibly 0 */
} as;
int iter_lev;
VALUE ifnone;
const VALUE ifnone;
};

#ifdef RHASH_ITER_LEV
Expand Down

0 comments on commit f75561b

Please sign in to comment.