diff options
author | yui-knk <spiketeika@gmail.com> | 2024-01-12 22:26:54 +0900 |
---|---|---|
committer | Yuichiro Kaneko <spiketeika@gmail.com> | 2024-01-23 08:58:16 +0900 |
commit | ee7f63ebba542f87e6fa28709e67ace0fefcae90 (patch) | |
tree | 2e6e772d4317bdd3ecbeed81ded30de12c69bb34 /ruby_parser.c | |
parent | 706eea9d3c27b9785fc7f650ff9b5d6669908768 (diff) | |
download | ruby-ee7f63ebba542f87e6fa28709e67ace0fefcae90.tar.gz |
Make lastline and nextline to be rb_parser_string
This commit changes `struct parser_params` lastline and nextline
from `VALUE` (String object) to `rb_parser_string_t *` so that
dependency on Ruby Object is reduced.
`parser_string_buffer_t string_buffer` is added to `struct parser_params`
to manage `rb_parser_string_t` pointers of each line. All allocated line
strings are freed in `rb_ruby_parser_free`.
Diffstat (limited to 'ruby_parser.c')
-rw-r--r-- | ruby_parser.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ruby_parser.c b/ruby_parser.c index d932b0f7be..965fe2cc1a 100644 --- a/ruby_parser.c +++ b/ruby_parser.c @@ -848,6 +848,12 @@ rb_parser_set_yydebug(VALUE vparser, VALUE flag) } #endif +VALUE +rb_str_new_parser_string(rb_parser_string_t *str) +{ + return rb_enc_str_new(str->ptr, str->len, str->enc); +} + static VALUE negative_numeric(VALUE val) { @@ -1000,6 +1006,5 @@ rb_node_line_lineno_val(const NODE *node) VALUE rb_node_file_path_val(const NODE *node) { - rb_parser_string_t *str = RNODE_FILE(node)->path; - return rb_enc_str_new(str->ptr, str->len, str->enc); + return rb_str_new_parser_string(RNODE_FILE(node)->path); } |