string.c: register_fstring
* string.c (register_fstring): separate registration from rb_fstring(). * string.c (rb_fstring_new): skip argument checks in rb_fstring(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
87954dd8a0
commit
0918c27a40
13
string.c
13
string.c
@ -212,6 +212,7 @@ static int fstring_cmp(VALUE a, VALUE b);
|
|||||||
|
|
||||||
/* in case we restart MVM development, this needs to be per-VM */
|
/* in case we restart MVM development, this needs to be per-VM */
|
||||||
static st_table* frozen_strings;
|
static st_table* frozen_strings;
|
||||||
|
static VALUE register_fstring(VALUE str);
|
||||||
|
|
||||||
static inline st_table*
|
static inline st_table*
|
||||||
rb_vm_fstring_table(void)
|
rb_vm_fstring_table(void)
|
||||||
@ -260,13 +261,19 @@ fstr_update_callback(st_data_t *key, st_data_t *value, st_data_t arg, int existi
|
|||||||
VALUE
|
VALUE
|
||||||
rb_fstring(VALUE str)
|
rb_fstring(VALUE str)
|
||||||
{
|
{
|
||||||
VALUE ret;
|
|
||||||
|
|
||||||
Check_Type(str, T_STRING);
|
Check_Type(str, T_STRING);
|
||||||
|
|
||||||
if (FL_TEST(str, RSTRING_FSTR))
|
if (FL_TEST(str, RSTRING_FSTR))
|
||||||
return str;
|
return str;
|
||||||
|
|
||||||
|
return register_fstring(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
register_fstring(VALUE str)
|
||||||
|
{
|
||||||
|
VALUE ret;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
ret = str;
|
ret = str;
|
||||||
st_update(rb_vm_fstring_table(), (st_data_t)str,
|
st_update(rb_vm_fstring_table(), (st_data_t)str,
|
||||||
@ -301,7 +308,7 @@ VALUE
|
|||||||
rb_fstring_new(const char *ptr, long len)
|
rb_fstring_new(const char *ptr, long len)
|
||||||
{
|
{
|
||||||
struct RString fake_str;
|
struct RString fake_str;
|
||||||
return rb_fstring(setup_fake_str(&fake_str, ptr, len, ENCINDEX_US_ASCII));
|
return register_fstring(setup_fake_str(&fake_str, ptr, len, ENCINDEX_US_ASCII));
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user