Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ext/json/ext/fbuffer/fbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ typedef struct FBufferStruct {
static void fbuffer_free(FBuffer *fb);
static void fbuffer_clear(FBuffer *fb);
static void fbuffer_append(FBuffer *fb, const char *newstr, size_t len);
static void fbuffer_append_long(FBuffer *fb, long number);
static void fbuffer_append_len(FBuffer *fb, rb_len_t number);
static inline void fbuffer_append_char(FBuffer *fb, char newchr);
static VALUE fbuffer_finalize(FBuffer *fb);

Expand Down Expand Up @@ -218,7 +218,7 @@ static inline void fbuffer_advance_to(FBuffer *fb, char *end)
/*
* Appends the decimal string representation of \a number into the buffer.
*/
static void fbuffer_append_long(FBuffer *fb, long number)
static void fbuffer_append_len(FBuffer *fb, rb_len_t number)
{
/*
* The jeaiii_ultoa() function produces digits left-to-right,
Expand All @@ -231,9 +231,9 @@ static void fbuffer_append_long(FBuffer *fb, long number)
* generated is therefore 20 (including a potential sign character).
*/

static const int MAX_CHARS_FOR_LONG = 20;
static const int MAX_CHARS_FOR_LEN = 20;

fbuffer_inc_capa(fb, MAX_CHARS_FOR_LONG);
fbuffer_inc_capa(fb, MAX_CHARS_FOR_LEN);

if (number < 0) {
fbuffer_append_reserved_char(fb, '-');
Expand Down
9 changes: 7 additions & 2 deletions ext/json/ext/generator/generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ struct generate_json_data {
long depth;
};

#if defined(HAVE_SIMD) && defined(HAVE_SIMD_SSE2)
static SIMD_Implementation simd_impl;
# define init_simd_impl() (simd_impl = find_simd_implementation())
#else
# define init_simd_impl() (void)0
#endif

static VALUE cState_from_state_s(VALUE self, VALUE opts);
static VALUE cState_partial_generate(VALUE self, VALUE obj, generator_func, VALUE io);
Expand Down Expand Up @@ -1161,7 +1166,7 @@ static void generate_json_fixnum(FBuffer *buffer, struct generate_json_data *dat
generate_json_rfc8785_number(buffer, obj);
return;
}
fbuffer_append_long(buffer, FIX2LONG(obj));
fbuffer_append_len(buffer, FIX2LEN(obj));
}

static void generate_json_bignum(FBuffer *buffer, struct generate_json_data *data, VALUE obj)
Expand Down Expand Up @@ -2171,5 +2176,5 @@ void Init_generator(void)

rb_require("json/ext/generator/state");

simd_impl = find_simd_implementation();
init_simd_impl();
}
7 changes: 7 additions & 0 deletions ext/json/ext/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@

#ifndef HAVE_RB_LEN_T
typedef long rb_len_t;
#endif
#ifndef FIX2LEN
# define FIX2LEN FIX2LONG
#endif
#ifndef LEN2NUM
# define LEN2NUM LONG2NUM
#endif
#ifndef PRIdLEN
# define PRIdLEN "ld"
#endif

Expand Down
Loading