diff options
author | Peter Zhu <[email protected]> | 2023-01-11 09:19:11 -0500 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2023-01-11 11:06:58 -0500 |
commit | d86833e717104b477c32e135a15fcbf380c6abb2 (patch) | |
tree | e01548e0bb6862c7173867c23ec736ecb091013f /internal/class.h | |
parent | a468213917b793c47d98e172b2f0a3853460c367 (diff) |
Make variation_count an unsigned char
Since SHAPE_MAX_VARIATIONS is 8, it can easily fit inside an unsigned
char.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7096
Diffstat (limited to 'internal/class.h')
-rw-r--r-- | internal/class.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/internal/class.h b/internal/class.h index 5731a5bc33..2af1a52666 100644 --- a/internal/class.h +++ b/internal/class.h @@ -11,6 +11,7 @@ #include "id_table.h" /* for struct rb_id_table */ #include "internal/gc.h" /* for RB_OBJ_WRITE */ #include "internal/serial.h" /* for rb_serial_t */ +#include "internal/static_assert.h" #include "ruby/internal/stdbool.h" /* for bool */ #include "ruby/intern.h" /* for rb_alloc_func_t */ #include "ruby/ruby.h" /* for struct RBasic */ @@ -25,6 +26,7 @@ struct rb_subclass_entry { struct rb_subclass_entry *next; struct rb_subclass_entry *prev; }; +typedef struct rb_subclass_entry rb_subclass_entry_t; struct rb_cvar_class_tbl_entry { uint32_t index; @@ -52,12 +54,15 @@ struct rb_classext_struct { const VALUE refined_class; rb_alloc_func_t allocator; const VALUE includer; - uint32_t max_iv_count; - uint32_t variation_count; #if !SHAPE_IN_BASIC_FLAGS shape_id_t shape_id; #endif + uint32_t max_iv_count; + unsigned char variation_count; }; +typedef struct rb_classext_struct rb_classext_t; + +STATIC_ASSERT(shape_max_variations, SHAPE_MAX_VARIATIONS < (1 << (sizeof(((rb_classext_t *)0)->variation_count) * CHAR_BIT))); struct RClass { struct RBasic basic; |