Skip to content

Commit

Permalink
Stop using rb_fstring publicly
Browse files Browse the repository at this point in the history
rb_fstring is a private API, so we should use rb_str_to_interned_str
instead, which is a public API.
  • Loading branch information
peterzhu2118 committed Feb 23, 2024
1 parent 01f9b2a commit 510404f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
6 changes: 2 additions & 4 deletions ext/-test-/string/fstring.c
Expand Up @@ -2,20 +2,18 @@
#include "ruby/encoding.h"
#include "internal/string.h"

VALUE rb_fstring(VALUE str);

VALUE
bug_s_fstring(VALUE self, VALUE str)
{
return rb_fstring(str);
return rb_str_to_interned_str(str);
}

VALUE
bug_s_fstring_fake_str(VALUE self)
{
static const char literal[] = "abcdefghijklmnopqrstuvwxyz";
struct RString fake_str;
return rb_fstring(rb_setup_fake_str(&fake_str, literal, sizeof(literal) - 1, 0));
return rb_str_to_interned_str(rb_setup_fake_str(&fake_str, literal, sizeof(literal) - 1, 0));
}

VALUE
Expand Down
4 changes: 1 addition & 3 deletions spec/ruby/optional/capi/ext/string_spec.c
Expand Up @@ -51,10 +51,8 @@ VALUE string_spec_rb_str_set_len_RSTRING_LEN(VALUE self, VALUE str, VALUE len) {
return INT2FIX(RSTRING_LEN(str));
}

VALUE rb_fstring(VALUE str); /* internal.h, used in ripper */

VALUE string_spec_rb_str_fstring(VALUE self, VALUE str) {
return rb_fstring(str);
return rb_str_to_interned_str(str);
}

VALUE string_spec_rb_str_buf_new(VALUE self, VALUE len, VALUE str) {
Expand Down
1 change: 0 additions & 1 deletion string.c
Expand Up @@ -398,7 +398,6 @@ fstr_update_callback(st_data_t *key, st_data_t *value, st_data_t data, int exist
}
}

RUBY_FUNC_EXPORTED
VALUE
rb_fstring(VALUE str)
{
Expand Down

0 comments on commit 510404f

Please sign in to comment.