diff options
| author | Jean Boussier <jean.boussier@gmail.com> | 2025-11-03 11:45:43 +0100 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2025-11-03 10:46:26 +0000 |
| commit | 52a17bbe6d778d56cc600f73f107c1992350f877 (patch) | |
| tree | 38033729a7ac0f8382d21a3726622065bc5c94bc /ext/json/parser/parser.c | |
| parent | 0832e954c9ef181563be0e70ba089ed0a8c0d02e (diff) | |
[ruby/json] parser.c: use `rb_str_to_interned_str` over `rb_funcall`
https://github.com/ruby/json/commit/21284ea649
Diffstat (limited to 'ext/json/parser/parser.c')
| -rw-r--r-- | ext/json/parser/parser.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/ext/json/parser/parser.c b/ext/json/parser/parser.c index 1e83dad915..25eeb89e77 100644 --- a/ext/json/parser/parser.c +++ b/ext/json/parser/parser.c @@ -16,7 +16,7 @@ static int utf8_encindex; #ifndef HAVE_RB_HASH_BULK_INSERT // For TruffleRuby -void +static void rb_hash_bulk_insert(long count, const VALUE *pairs, VALUE hash) { long index = 0; @@ -33,6 +33,12 @@ rb_hash_bulk_insert(long count, const VALUE *pairs, VALUE hash) #define rb_hash_new_capa(n) rb_hash_new() #endif +#ifndef HAVE_RB_STR_TO_INTERNED_STR +static VALUE rb_str_to_interned_str(VALUE str) +{ + return rb_funcall(rb_str_freeze(str), i_uminus, 0); +} +#endif /* name cache */ @@ -703,7 +709,7 @@ static VALUE json_string_unescape(JSON_ParserState *state, const char *string, c if (symbolize) { result = rb_str_intern(result); } else if (intern) { - result = rb_funcall(rb_str_freeze(result), i_uminus, 0); + result = rb_str_to_interned_str(result); } return result; @@ -1310,6 +1316,7 @@ static VALUE json_parse_any(JSON_ParserState *state, JSON_ParserConfig *config) } raise_parse_error("unreachable: %s", state); + return Qundef; } static void json_ensure_eof(JSON_ParserState *state) |
