diff options
author | Jean Boussier <[email protected]> | 2024-04-10 10:50:18 +0200 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2024-04-11 09:04:31 +0200 |
commit | 1b830740ba8371c4bcfdfc6eb2cb7e0ae81a84e0 (patch) | |
tree | 7f4b1c983035adaaa52bf966e54f1f4738098d4c /internal/ruby_parser.h | |
parent | ed303cd56cfc7889ce371ee390e9fd36f86814ea (diff) |
compile.c: use rb_enc_interned_str to reduce allocations
The `rb_fstring(rb_enc_str_new())` pattern is inneficient because:
- It passes a mutable string to `rb_fstring` so if it has to be interned
it will first be duped.
- It an equivalent interned string already exists, we allocated the string
for nothing.
With `rb_enc_interned_str` we either directly get the pre-existing string
with 0 allocations, or efficiently directly intern the one we create
without first duping it.
Diffstat (limited to 'internal/ruby_parser.h')
-rw-r--r-- | internal/ruby_parser.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/internal/ruby_parser.h b/internal/ruby_parser.h index 7dc6a46d4f..0a00075211 100644 --- a/internal/ruby_parser.h +++ b/internal/ruby_parser.h @@ -19,6 +19,7 @@ VALUE rb_parser_set_context(VALUE, const struct rb_iseq_struct *, int); VALUE rb_parser_new(void); rb_ast_t *rb_parser_compile_string_path(VALUE vparser, VALUE fname, VALUE src, int line); VALUE rb_str_new_parser_string(rb_parser_string_t *str); +VALUE rb_str_new_mutable_parser_string(rb_parser_string_t *str); VALUE rb_node_str_string_val(const NODE *); VALUE rb_node_sym_string_val(const NODE *); |