diff options
| author | Jean Boussier <jean.boussier@gmail.com> | 2026-04-08 09:21:34 +0200 |
|---|---|---|
| committer | Jean Boussier <jean.boussier@gmail.com> | 2026-04-08 10:25:34 +0200 |
| commit | 1fb0aca3bac9544c01143a768f638fcfad7cff9c (patch) | |
| tree | fa01540ee0ae2124762e20a54f4834efa22545ee | |
| parent | 24a2ba09af13b7c969733ea9370ad59d2442f4c9 (diff) | |
imemo.h: Extract rb_imemo_needs_cleanup_p
| -rw-r--r-- | gc.c | 13 | ||||
| -rw-r--r-- | internal/imemo.h | 26 |
2 files changed, 26 insertions, 13 deletions
@@ -1313,18 +1313,7 @@ rb_gc_obj_needs_cleanup_p(VALUE obj) switch (flags & RUBY_T_MASK) { case T_IMEMO: - switch (imemo_type(obj)) { - case imemo_constcache: - case imemo_cref: - case imemo_ifunc: - case imemo_memo: - case imemo_svar: - case imemo_callcache: - case imemo_throw_data: - return false; - default: - return true; - } + return rb_imemo_needs_cleanup_p(obj); case T_DATA: case T_OBJECT: diff --git a/internal/imemo.h b/internal/imemo.h index c5c0d005f1..2ccb42c85e 100644 --- a/internal/imemo.h +++ b/internal/imemo.h @@ -40,7 +40,7 @@ enum imemo_type { imemo_callinfo = 10, imemo_callcache = 11, imemo_constcache = 12, - imemo_fields = 13, + imemo_fields = 13, }; /* CREF (Class REFerence) is defined in method.h */ @@ -292,4 +292,28 @@ rb_imemo_fields_complex_tbl(VALUE fields_obj) return IMEMO_OBJ_FIELDS(fields_obj)->as.complex.table; } +static inline bool +rb_imemo_needs_cleanup_p(VALUE obj) +{ + switch (imemo_type(obj)) { + case imemo_constcache: + case imemo_cref: + case imemo_ifunc: + case imemo_memo: + case imemo_svar: + case imemo_callcache: + case imemo_throw_data: + return false; + + case imemo_env: + case imemo_ment: + case imemo_iseq: + case imemo_callinfo: + case imemo_fields: + case imemo_tmpbuf: + return true; + } + UNREACHABLE_RETURN(true); +} + #endif /* INTERNAL_IMEMO_H */ |
