This is an automated email from the ASF dual-hosted git repository. nickva pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/couchdb-jiffy.git
commit 024386313a07d3c5d41546f6ccec9aafc3db763d Author: Nick Vatamaniuc <[email protected]> AuthorDate: Tue Mar 31 00:49:45 2026 -0400 Make most of decode functions static Since we did this to the encoder, it seems right to do likewise to the decoder. Add some "inline" suggestions to the compiler for some smaller ones. Saw encoder used some of those so it fits here as well. --- c_src/decoder.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/c_src/decoder.c b/c_src/decoder.c index f3fcc7f..1f39394 100644 --- a/c_src/decoder.c +++ b/c_src/decoder.c @@ -65,7 +65,7 @@ typedef struct { // Returns an allocated resource or crashes the VM. No need to // check return pointer for NULL -Decoder* +static Decoder* dec_new(ErlNifEnv* env) { jiffy_st* st = (jiffy_st*) enif_priv_data(env); @@ -102,7 +102,7 @@ dec_new(ErlNifEnv* env) return d; } -void +static void dec_init(Decoder* d, ErlNifEnv* env, ERL_NIF_TERM arg, ErlNifBinary* bin) { d->env = env; @@ -122,7 +122,7 @@ dec_destroy(ErlNifEnv* env, void* obj) } } -ERL_NIF_TERM +static ERL_NIF_TERM dec_error(Decoder* d, const char* atom) { ERL_NIF_TERM pos = enif_make_int(d->env, d->i+1); @@ -131,20 +131,20 @@ dec_error(Decoder* d, const char* atom) return enif_make_tuple2(d->env, d->atoms->atom_error, ret); } -char +static inline char dec_curr(Decoder* d) { assert(d->st_top > 0); return d->st_data[d->st_top - 1]; } -int +static inline int dec_top(Decoder* d) { return d->st_top; } -void +static inline void dec_push(Decoder* d, char val) { int new_sz; @@ -163,7 +163,7 @@ dec_push(Decoder* d, char val) d->st_data[d->st_top++] = val; } -char +static inline char dec_pop(Decoder* d) { char current = st_invalid; @@ -176,7 +176,7 @@ dec_pop(Decoder* d) { return current; } -void +static void dec_pop_assert(Decoder* d, char val) { char current = dec_pop(d); @@ -184,7 +184,7 @@ dec_pop_assert(Decoder* d, char val) (void)current; } -int +static int dec_string(Decoder* d, ERL_NIF_TERM* value) { int has_escape = 0; @@ -368,7 +368,7 @@ parse: return 1; } -int +static int dec_number(Decoder* d, ERL_NIF_TERM* value) { ERL_NIF_TERM num_type = d->atoms->atom_error; @@ -615,7 +615,7 @@ parse: return 1; } -ERL_NIF_TERM +static ERL_NIF_TERM make_empty_object(ErlNifEnv* env, int ret_map) { if(ret_map) { @@ -625,7 +625,7 @@ make_empty_object(ErlNifEnv* env, int ret_map) return enif_make_tuple1(env, enif_make_list(env, 0)); } -ERL_NIF_TERM +static inline ERL_NIF_TERM make_array(ErlNifEnv* env, ERL_NIF_TERM list) { ERL_NIF_TERM ret = enif_make_list(env, 0);
