diff options
author | Jean Boussier <[email protected]> | 2025-01-16 14:53:51 +0100 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2025-01-20 16:09:00 +0900 |
commit | e4b54b0a3638ed89c6c0a9ca3f10b990b2bb008d () | |
tree | f8573517c55d93d86224c7116e8628f97618684f /ext/json/fbuffer | |
parent | 99e9eb5380a7a58880bef459c740e91369b8dab2 (diff) |
[ruby/json] Replace fbuffer by stack buffers or RB_ALLOCV in parser.c
We only use that buffer for parsing integer and floats, these are unlikely to be very big, and if so we can just use RB_ALLOCV as it will almost always end in a small `alloca`. This allow to no longer need `rb_protect` around the parser. https://.com/ruby/json/commit/994859916a
Notes: Merged: https://.com/ruby/ruby/pull/12598
-rw-r--r-- | ext/json/fbuffer/fbuffer.h | 11 |
1 files changed, 1 insertions, 10 deletions
@@ -59,17 +59,11 @@ typedef struct FBufferStruct { #define FBUFFER_PAIR(fb) FBUFFER_PTR(fb), FBUFFER_LEN(fb) static void fbuffer_free(FBuffer *fb); -#ifndef JSON_GENERATOR static void fbuffer_clear(FBuffer *fb); -#endif static void fbuffer_append(FBuffer *fb, const char *newstr, unsigned long len); -#ifdef JSON_GENERATOR static void fbuffer_append_long(FBuffer *fb, long number); -#endif static inline void fbuffer_append_char(FBuffer *fb, char newchr); -#ifdef JSON_GENERATOR static VALUE fbuffer_finalize(FBuffer *fb); -#endif static void fbuffer_stack_init(FBuffer *fb, unsigned long initial_length, char *stack_buffer, long stack_buffer_size) { @@ -156,7 +150,6 @@ static void fbuffer_append(FBuffer *fb, const char *newstr, unsigned long len) } } -#ifdef JSON_GENERATOR static void fbuffer_append_str(FBuffer *fb, VALUE str) { const char *newstr = StringValuePtr(str); @@ -166,7 +159,6 @@ static void fbuffer_append_str(FBuffer *fb, VALUE str) fbuffer_append(fb, newstr, len); } -#endif static inline void fbuffer_append_char(FBuffer *fb, char newchr) { @@ -175,7 +167,6 @@ static inline void fbuffer_append_char(FBuffer *fb, char newchr) fb->len++; } -#ifdef JSON_GENERATOR static long fltoa(long number, char *buf) { static const char digits[] = "0123456789"; @@ -210,5 +201,5 @@ static VALUE fbuffer_finalize(FBuffer *fb) return result; } } -#endif #endif |