Skip to content

Commit ef19fb1

Browse files
byrootko1
authored andcommitted
Expose the rb_interned_str_* family of functions
Fixes [Feature ruby#13381]
1 parent 68ffc8d commit ef19fb1

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

include/ruby/encoding.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ void rb_enc_copy(VALUE dst, VALUE src);
127127
VALUE rb_enc_str_new(const char*, long, rb_encoding*);
128128
VALUE rb_enc_str_new_cstr(const char*, rb_encoding*);
129129
VALUE rb_enc_str_new_static(const char*, long, rb_encoding*);
130+
VALUE rb_enc_interned_str(const char *, long, rb_encoding *);
131+
VALUE rb_enc_interned_str_cstr(const char *, rb_encoding *);
130132
VALUE rb_enc_reg_new(const char*, long, rb_encoding*, int);
131133
PRINTF_ARGS(VALUE rb_enc_sprintf(rb_encoding *, const char*, ...), 2, 3);
132134
VALUE rb_enc_vsprintf(rb_encoding *, const char*, va_list);

include/ruby/internal/intern/string.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ VALUE rb_utf8_str_new_cstr(const char*);
7474
VALUE rb_str_new_static(const char *ptr, long len);
7575
VALUE rb_usascii_str_new_static(const char *ptr, long len);
7676
VALUE rb_utf8_str_new_static(const char *ptr, long len);
77+
VALUE rb_str_to_interned_str(VALUE);
78+
VALUE rb_interned_str(const char *, long);
79+
VALUE rb_interned_str_cstr(const char *);
7780
void rb_str_free(VALUE);
7881
void rb_str_shared_replace(VALUE, VALUE);
7982
VALUE rb_str_buf_append(VALUE, VALUE);

string.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11402,6 +11402,36 @@ sym_all_symbols(VALUE _)
1140211402
return rb_sym_all_symbols();
1140311403
}
1140411404

11405+
VALUE
11406+
rb_str_to_interned_str(VALUE str)
11407+
{
11408+
return rb_fstring(str);
11409+
}
11410+
11411+
VALUE
11412+
rb_interned_str(const char *ptr, long len)
11413+
{
11414+
return rb_fstring_new(ptr, len);
11415+
}
11416+
11417+
VALUE
11418+
rb_interned_str_cstr(const char *ptr)
11419+
{
11420+
return rb_fstring_cstr(ptr);
11421+
}
11422+
11423+
VALUE
11424+
rb_enc_interned_str(const char *ptr, long len, rb_encoding *enc)
11425+
{
11426+
return rb_fstring_enc_new(ptr, len, enc);
11427+
}
11428+
11429+
VALUE
11430+
rb_enc_interned_str_cstr(const char *ptr, rb_encoding *enc)
11431+
{
11432+
return rb_fstring_enc_new(ptr, strlen(ptr), enc);
11433+
}
11434+
1140511435
/*
1140611436
* A String object holds and manipulates an arbitrary sequence of
1140711437
* bytes, typically representing characters. String objects may be created

0 commit comments

Comments
 (0)