[前][次][番号順一覧][スレッド一覧]

ruby-changes:38225

From: nobu <ko1@a...>
Date: Tue, 14 Apr 2015 12:31:49 +0900 (JST)
Subject: [ruby-changes:38225] nobu:r50306 (trunk): use frozen string of symbols

nobu	2015-04-14 12:31:28 +0900 (Tue, 14 Apr 2015)

  New Revision: 50306

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50306

  Log:
    use frozen string of symbols
    
    * 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.

  Modified files:
    trunk/ext/socket/constants.c
    trunk/range.c
    trunk/re.c
Index: re.c
===================================================================
--- re.c	(revision 50305)
+++ re.c	(revision 50306)
@@ -2753,7 +2753,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/re.c#L2753
 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);
Index: range.c
===================================================================
--- range.c	(revision 50305)
+++ range.c	(revision 50306)
@@ -429,11 +429,11 @@ range_step(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/range.c#L429
     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 */
@@ -771,9 +771,9 @@ range_each(VALUE range) https://github.com/ruby/ruby/blob/trunk/range.c#L771
     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);
Index: ext/socket/constants.c
===================================================================
--- ext/socket/constants.c	(revision 50305)
+++ ext/socket/constants.c	(revision 50306)
@@ -22,7 +22,7 @@ constant_arg(VALUE arg, int (*str_to_int https://github.com/ruby/ruby/blob/trunk/ext/socket/constants.c#L22
     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))) {

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]