diff options
author | Yusuke Endoh <[email protected]> | 2023-12-27 15:57:02 +0900 |
---|---|---|
committer | git <[email protected]> | 2024-10-17 08:54:47 +0000 |
commit | 64c24f6971ba0341a189eefb64368cf009fbb79d () | |
tree | 4b3ac4fd0d5d917cd436c1eda9d1143dd9284575 /ext/json/fbuffer | |
parent | 186e77209e74c3f7643ae6396ad3dbba8a5c6977 (diff) |
[ruby/json] Stop prebuilding object_delim2
Also, remove static functions that are no longer used. This speeds up `JSON.generate` by about 5% in a benchmark. https://.com/ruby/json/commit/4c984b2017
-rw-r--r-- | ext/json/fbuffer/fbuffer.h | 15 |
1 files changed, 4 insertions, 11 deletions
@@ -55,14 +55,15 @@ typedef struct FBufferStruct { static FBuffer *fbuffer_alloc(unsigned long initial_length); static void fbuffer_free(FBuffer *fb); static void fbuffer_clear(FBuffer *fb); 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 void fbuffer_append_char(FBuffer *fb, char newchr); #ifdef JSON_GENERATOR -static FBuffer *fbuffer_dup(FBuffer *fb); static VALUE fbuffer_to_s(FBuffer *fb); #endif @@ -86,10 +87,12 @@ static void fbuffer_free(FBuffer *fb) ruby_xfree(fb); } static void fbuffer_clear(FBuffer *fb) { fb->len = 0; } static inline void fbuffer_inc_capa(FBuffer *fb, unsigned long requested) { @@ -168,16 +171,6 @@ static void fbuffer_append_long(FBuffer *fb, long number) fbuffer_append(fb, buf, len); } -static FBuffer *fbuffer_dup(FBuffer *fb) -{ - unsigned long len = fb->len; - FBuffer *result; - - result = fbuffer_alloc(len); - fbuffer_append(result, FBUFFER_PAIR(fb)); - return result; -} - static VALUE fbuffer_to_s(FBuffer *fb) { VALUE result = rb_str_new(FBUFFER_PTR(fb), FBUFFER_LEN(fb)); |