summaryrefslogtreecommitdiff
path: root/shape.h
diff options
context:
space:
mode:
authorJean Boussier <byroot@ruby-lang.org>2023-10-10 22:17:30 +0200
committerJean Boussier <jean.boussier@gmail.com>2023-10-11 08:33:09 +0200
commite3afc212ec059525fe4e5387b2a3be920ffe0f0e (patch)
treecf315265d2a60f91186ea4c455ec3a2504ebd79e /shape.h
parente5d97308f646dc5702ebab3c8d1b6383aaf4ad94 (diff)
shape.h: Make attr_index_t uint8_t
Given `SHAPE_MAX_NUM_IVS 80`, we transition to TOO_COMPLEX way before we could overflow a 8bit counter. This reduce the size of `rb_shape_t` from 32B to 24B. If we decide to raise `SHAPE_MAX_NUM_IVS` we can always increase that type again.
Diffstat (limited to 'shape.h')
-rw-r--r--shape.h5
1 files changed, 2 insertions, 3 deletions
diff --git a/shape.h b/shape.h
index 5689b48067..1b2221ad76 100644
--- a/shape.h
+++ b/shape.h
@@ -6,12 +6,11 @@
#if (SIZEOF_UINT64_T <= SIZEOF_VALUE)
#define SIZEOF_SHAPE_T 4
#define SHAPE_IN_BASIC_FLAGS 1
-typedef uint32_t attr_index_t;
#else
#define SIZEOF_SHAPE_T 2
#define SHAPE_IN_BASIC_FLAGS 0
-typedef uint16_t attr_index_t;
#endif
+typedef uint8_t attr_index_t;
#define MAX_IVARS (attr_index_t)(-1)
@@ -44,7 +43,7 @@ struct rb_shape {
struct rb_id_table * edges; // id_table from ID (ivar) to next shape
ID edge_name; // ID (ivar) for transition from parent to rb_shape
attr_index_t next_iv_index;
- uint32_t capacity; // Total capacity of the object with this shape
+ attr_index_t capacity; // Total capacity of the object with this shape
uint8_t type;
uint8_t size_pool_index;
shape_id_t parent_id;