diff options
author | Florian Frank <flori@ping.de> | 2009-11-06 00:25:03 +0100 |
---|---|---|
committer | Florian Frank <flori@ping.de> | 2009-11-07 14:41:23 +0100 |
commit | 21b1abd1171dcad15205ad3a815e1dc06e29bdec (patch) | |
tree | 01001648cfe51ca3c4d9e7e22aaec88de0099ad7 /ext | |
parent | 15a6246ec0b32272014fce1d023ac8c933d898dd (diff) | |
download | json-21b1abd1171dcad15205ad3a815e1dc06e29bdec.tar.gz |
make inc function static, optimised a bit
Diffstat (limited to 'ext')
-rw-r--r-- | ext/json/ext/generator/fbuffer.c | 2 | ||||
-rw-r--r-- | ext/json/ext/generator/fbuffer.h | 1 | ||||
-rw-r--r-- | ext/json/ext/generator/generator.c | 14 |
3 files changed, 9 insertions, 8 deletions
diff --git a/ext/json/ext/generator/fbuffer.c b/ext/json/ext/generator/fbuffer.c index 0448a8d..c87df6a 100644 --- a/ext/json/ext/generator/fbuffer.c +++ b/ext/json/ext/generator/fbuffer.c @@ -29,7 +29,7 @@ inline void fbuffer_clear(FBuffer *fb) fb->len = 0; } -inline void fbuffer_inc_capa(FBuffer *fb, unsigned int requested) +static inline void fbuffer_inc_capa(FBuffer *fb, unsigned int requested) { unsigned int required; diff --git a/ext/json/ext/generator/fbuffer.h b/ext/json/ext/generator/fbuffer.h index 7641470..0fa8850 100644 --- a/ext/json/ext/generator/fbuffer.h +++ b/ext/json/ext/generator/fbuffer.h @@ -21,7 +21,6 @@ inline FBuffer *fbuffer_alloc(); inline FBuffer *fbuffer_alloc_with_length(unsigned initial_length); inline void fbuffer_free(FBuffer *fb); inline void fbuffer_clear(FBuffer *fb); -inline void fbuffer_inc_capa(FBuffer *fb, unsigned int requested); inline void fbuffer_append(FBuffer *fb, const char *newstr, unsigned int len); inline void fbuffer_append_char(FBuffer *fb, char newchr); diff --git a/ext/json/ext/generator/generator.c b/ext/json/ext/generator/generator.c index ac2eb8f..4634cc9 100644 --- a/ext/json/ext/generator/generator.c +++ b/ext/json/ext/generator/generator.c @@ -498,12 +498,14 @@ void generate_json(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, V char allow_nan = state->allow_nan; double value = RFLOAT_VALUE(obj); tmp = rb_funcall(obj, i_to_s, 0); - if (!allow_nan && isinf(value)) { - fbuffer_free(buffer); - rb_raise(eGeneratorError, "%u: %s not allowed in JSON", __LINE__, StringValueCStr(tmp)); - } else if (!allow_nan && isnan(value)) { - fbuffer_free(buffer); - rb_raise(eGeneratorError, "%u: %s not allowed in JSON", __LINE__, StringValueCStr(tmp)); + if (!allow_nan) { + if (isinf(value)) { + fbuffer_free(buffer); + rb_raise(eGeneratorError, "%u: %s not allowed in JSON", __LINE__, StringValueCStr(tmp)); + } else if (isnan(value)) { + fbuffer_free(buffer); + rb_raise(eGeneratorError, "%u: %s not allowed in JSON", __LINE__, StringValueCStr(tmp)); + } } fbuffer_append(buffer, RSTRING_PAIR(tmp)); } |