Skip to content

Commit 0292b70

Browse files
committed
shape.h: make RSHAPE static inline
Since the shape_tree_ptr is `extern` it should be possible to fully inline `RSHAPE`.
1 parent d55c463 commit 0292b70

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

shape.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,7 @@ rb_shape_each_shape_id(each_shape_callback callback, void *data)
383383
RUBY_FUNC_EXPORTED rb_shape_t *
384384
rb_shape_lookup(shape_id_t shape_id)
385385
{
386-
uint32_t offset = (shape_id & SHAPE_ID_OFFSET_MASK);
387-
RUBY_ASSERT(offset != INVALID_SHAPE_ID);
388-
389-
return &GET_SHAPE_TREE()->shape_list[offset];
386+
return RSHAPE(shape_id);
390387
}
391388

392389
RUBY_FUNC_EXPORTED shape_id_t

shape.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ typedef struct {
9292
redblack_node_t *shape_cache;
9393
unsigned int cache_size;
9494
} rb_shape_tree_t;
95+
96+
RUBY_SYMBOL_EXPORT_BEGIN
9597
RUBY_EXTERN rb_shape_tree_t *rb_shape_tree_ptr;
98+
RUBY_SYMBOL_EXPORT_END
9699

97100
union rb_attr_index_cache {
98101
uint64_t pack;
@@ -149,7 +152,14 @@ RBASIC_SET_SHAPE_ID(VALUE obj, shape_id_t shape_id)
149152
#endif
150153
}
151154

152-
#define RSHAPE rb_shape_lookup
155+
static inline rb_shape_t *
156+
RSHAPE(shape_id_t shape_id)
157+
{
158+
uint32_t offset = (shape_id & SHAPE_ID_OFFSET_MASK);
159+
RUBY_ASSERT(offset != INVALID_SHAPE_ID);
160+
161+
return &GET_SHAPE_TREE()->shape_list[offset];
162+
}
153163

154164
int32_t rb_shape_id_offset(void);
155165

0 commit comments

Comments
 (0)