Skip to content

Commit

Permalink
encoding.c: make fstring
Browse files Browse the repository at this point in the history
* encoding.c (enc_name, rb_enc_name_list_i, rb_enc_aliases_enc_i):
  make fstring instead of making each copies.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Dec 2, 2015
1 parent 7afefea commit e86f66b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Wed Dec 2 17:00:54 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>

* encoding.c (enc_name, rb_enc_name_list_i, rb_enc_aliases_enc_i):
make fstring instead of making each copies.

Wed Dec 2 16:32:08 2015 Koichi Sasada <ko1@atdot.net>

* iseq.h: introduce ISEQ_COMPILE_DATA() macro.
Expand Down
8 changes: 3 additions & 5 deletions encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ enc_inspect(VALUE self)
static VALUE
enc_name(VALUE self)
{
return rb_usascii_str_new2(rb_enc_name((rb_encoding*)DATA_PTR(self)));
return rb_fstring_cstr(rb_enc_name((rb_encoding*)DATA_PTR(self)));
}

static int
Expand Down Expand Up @@ -1633,8 +1633,7 @@ static int
rb_enc_name_list_i(st_data_t name, st_data_t idx, st_data_t arg)
{
VALUE ary = (VALUE)arg;
VALUE str = rb_usascii_str_new2((char *)name);
OBJ_FREEZE(str);
VALUE str = rb_fstring_cstr((char *)name);
rb_ary_push(ary, str);
return ST_CONTINUE;
}
Expand Down Expand Up @@ -1676,8 +1675,7 @@ rb_enc_aliases_enc_i(st_data_t name, st_data_t orig, st_data_t arg)
if (STRCASECMP((char*)name, rb_enc_name(enc)) == 0) {
return ST_CONTINUE;
}
str = rb_usascii_str_new2(rb_enc_name(enc));
OBJ_FREEZE(str);
str = rb_fstring_cstr(rb_enc_name(enc));
rb_ary_store(ary, idx, str);
}
key = rb_usascii_str_new2((char *)name);
Expand Down

0 comments on commit e86f66b

Please sign in to comment.