Skip to content

Commit 5cb9bd5

Browse files
authored
Merge pull request #208 from Shopify/add_darray_clear
Add rb_darray_clear() for Kevin. Fix some warnings.
2 parents 610ada7 + 35caa9d commit 5cb9bd5

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

darray.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@
8484
//
8585
#define rb_darray_make(ptr_to_ary, size) rb_darray_make_impl((ptr_to_ary), size, sizeof(**(ptr_to_ary)), sizeof((*(ptr_to_ary))->data[0]))
8686

87+
// Set the size of the array to zero without freeing the backing memory.
88+
// Allows reusing the same array.
89+
//
90+
#define rb_darray_clear(ary) (ary->meta.size = 0)
91+
8792
typedef struct rb_darray_meta {
8893
int32_t size;
8994
int32_t capa;

yjit_codegen.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ jit_peek_at_self(jitstate_t *jit, ctx_t *ctx)
142142
return jit->ec->cfp->self;
143143
}
144144

145+
RBIMPL_ATTR_MAYBE_UNUSED()
145146
static VALUE
146147
jit_peek_at_local(jitstate_t *jit, ctx_t *ctx, int n)
147148
{
@@ -985,7 +986,7 @@ gen_expandarray(jitstate_t* jit, ctx_t* ctx)
985986

986987
// num is the number of requested values. If there aren't enough in the
987988
// array then we're going to push on nils.
988-
rb_num_t num = (rb_num_t) jit_get_arg(jit, 0);
989+
int num = (int)jit_get_arg(jit, 0);
989990
val_type_t array_type = ctx_get_opnd_type(ctx, OPND_STACK(0));
990991
x86opnd_t array_opnd = ctx_stack_pop(ctx, 1);
991992

0 commit comments

Comments
 (0)