Skip to content

Commit

Permalink
use frozen string of symbols
Browse files Browse the repository at this point in the history
* range.c (range_step, range_each): String#upto should never
  modifies the receiver, use frozen strings to enumerate symbols.

* re.c (reg_operand): matching target is not modified.

* ext/socket/constants.c (constant_arg): str_to_int never modifies
  argument strings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Apr 14, 2015
1 parent 3dba6da commit 523ecd2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ext/socket/constants.c
Expand Up @@ -22,7 +22,7 @@ constant_arg(VALUE arg, int (*str_to_int)(const char*, long, int*), const char *
int ret;

if (SYMBOL_P(arg)) {
arg = rb_sym_to_s(arg);
arg = rb_sym2str(arg);
goto str;
}
else if (!NIL_P(tmp = rb_check_string_type(arg))) {
Expand Down
8 changes: 4 additions & 4 deletions range.c
Expand Up @@ -429,11 +429,11 @@ range_step(int argc, VALUE *argv, VALUE range)
else if (SYMBOL_P(b) && SYMBOL_P(e)) { /* symbols are special */
VALUE args[2], iter[2];

args[0] = rb_sym_to_s(e);
args[0] = rb_sym2str(e);
args[1] = EXCL(range) ? Qtrue : Qfalse;
iter[0] = INT2FIX(1);
iter[1] = step;
rb_block_call(rb_sym_to_s(b), rb_intern("upto"), 2, args, sym_step_i, (VALUE)iter);
rb_block_call(rb_sym2str(b), rb_intern("upto"), 2, args, sym_step_i, (VALUE)iter);
}
else if (ruby_float_step(b, e, step, EXCL(range))) {
/* done */
Expand Down Expand Up @@ -771,9 +771,9 @@ range_each(VALUE range)
else if (SYMBOL_P(beg) && SYMBOL_P(end)) { /* symbols are special */
VALUE args[2];

args[0] = rb_sym_to_s(end);
args[0] = rb_sym2str(end);
args[1] = EXCL(range) ? Qtrue : Qfalse;
rb_block_call(rb_sym_to_s(beg), rb_intern("upto"), 2, args, sym_each_i, 0);
rb_block_call(rb_sym2str(beg), rb_intern("upto"), 2, args, sym_each_i, 0);
}
else {
VALUE tmp = rb_check_string_type(beg);
Expand Down
2 changes: 1 addition & 1 deletion re.c
Expand Up @@ -2753,7 +2753,7 @@ static VALUE
reg_operand(VALUE s, int check)
{
if (SYMBOL_P(s)) {
return rb_sym_to_s(s);
return rb_sym2str(s);
}
else {
return (check ? rb_str_to_str : rb_check_string_type)(s);
Expand Down

0 comments on commit 523ecd2

Please sign in to comment.