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

ruby-changes:57962

From: Aaron <ko1@a...>
Date: Fri, 27 Sep 2019 06:22:56 +0900 (JST)
Subject: [ruby-changes:57962] 4808afb360 (master): Replace `freeze_string` with `rb_fstring`

https://git.ruby-lang.org/ruby.git/commit/?id=4808afb360

From 4808afb360c58e26669fec5a60a55088e16fdb4a Mon Sep 17 00:00:00 2001
From: Aaron Patterson <tenderlove@r...>
Date: Thu, 26 Sep 2019 13:19:11 -0700
Subject: Replace `freeze_string` with `rb_fstring`


diff --git a/compile.c b/compile.c
index a95b9c2..59ee138 100644
--- a/compile.c
+++ b/compile.c
@@ -575,12 +575,6 @@ APPEND_ELEM(ISEQ_ARG_DECLARE LINK_ANCHOR *const anchor, LINK_ELEMENT *before, LI https://github.com/ruby/ruby/blob/trunk/compile.c#L575
 
 #define ISEQ_LAST_LINE(iseq) (ISEQ_COMPILE_DATA(iseq)->last_line)
 
-static inline VALUE
-freeze_literal(rb_iseq_t *iseq, VALUE lit)
-{
-    return rb_fstring(lit);
-}
-
 static int
 validate_label(st_data_t name, st_data_t label, st_data_t arg)
 {
@@ -3644,7 +3638,7 @@ compile_dstr_fragments(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *cons https://github.com/ruby/ruby/blob/trunk/compile.c#L3638
 			  rb_builtin_type_name(TYPE(lit)));
 	    return COMPILE_NG;
 	}
-	lit = freeze_literal(iseq, lit);
+	lit = rb_fstring(lit);
 	ADD_INSN1(ret, nd_line(node), putobject, lit);
         RB_OBJ_WRITTEN(iseq, Qundef, lit);
 	if (RSTRING_LEN(lit) == 0) first_lit = LAST_ELEMENT(ret);
@@ -3653,7 +3647,7 @@ compile_dstr_fragments(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *cons https://github.com/ruby/ruby/blob/trunk/compile.c#L3647
     while (list) {
 	const NODE *const head = list->nd_head;
 	if (nd_type(head) == NODE_STR) {
-	    lit = freeze_literal(iseq, head->nd_lit);
+	    lit = rb_fstring(head->nd_lit);
 	    ADD_INSN1(ret, nd_line(head), putobject, lit);
             RB_OBJ_WRITTEN(iseq, Qundef, lit);
 	    lit = Qnil;
@@ -4272,7 +4266,7 @@ when_vals(rb_iseq_t *iseq, LINK_ANCHOR *const cond_seq, const NODE *vals, https://github.com/ruby/ruby/blob/trunk/compile.c#L4266
 
 	if (nd_type(val) == NODE_STR) {
 	    debugp_param("nd_lit", val->nd_lit);
-	    lit = freeze_literal(iseq, val->nd_lit);
+	    lit = rb_fstring(val->nd_lit);
 	    ADD_INSN1(cond_seq, nd_line(val), putobject, lit);
             RB_OBJ_WRITTEN(iseq, Qundef, lit);
 	}
@@ -6646,7 +6640,7 @@ compile_call_precheck_freeze(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE https://github.com/ruby/ruby/blob/trunk/compile.c#L6640
         node->nd_args == NULL &&
         ISEQ_COMPILE_DATA(iseq)->current_block == NULL &&
         ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction) {
-        VALUE str = freeze_literal(iseq, node->nd_recv->nd_lit);
+        VALUE str = rb_fstring(node->nd_recv->nd_lit);
         if (node->nd_mid == idUMinus) {
             ADD_INSN3(ret, line, opt_str_uminus, str,
                       new_callinfo(iseq, idUMinus, 0, 0, NULL, FALSE),
@@ -6672,7 +6666,7 @@ compile_call_precheck_freeze(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE https://github.com/ruby/ruby/blob/trunk/compile.c#L6666
         ISEQ_COMPILE_DATA(iseq)->current_block == NULL &&
         !ISEQ_COMPILE_DATA(iseq)->option->frozen_string_literal &&
         ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction) {
-        VALUE str = freeze_literal(iseq, node->nd_args->nd_head->nd_lit);
+        VALUE str = rb_fstring(node->nd_args->nd_head->nd_lit);
         CHECK(COMPILE(ret, "recv", node->nd_recv));
         ADD_INSN3(ret, line, opt_aref_with, str,
                   new_callinfo(iseq, idAREF, 1, 0, NULL, FALSE),
@@ -7752,7 +7746,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in https://github.com/ruby/ruby/blob/trunk/compile.c#L7746
 	if (!popped) {
 	    VALUE lit = node->nd_lit;
 	    if (!ISEQ_COMPILE_DATA(iseq)->option->frozen_string_literal) {
-		lit = freeze_literal(iseq, lit);
+		lit = rb_fstring(lit);
 		ADD_INSN1(ret, line, putstring, lit);
                 RB_OBJ_WRITTEN(iseq, Qundef, lit);
 	    }
@@ -7794,7 +7788,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in https://github.com/ruby/ruby/blob/trunk/compile.c#L7788
       }
       case NODE_XSTR:{
 	ADD_CALL_RECEIVER(ret, line);
-        VALUE str = freeze_literal(iseq, node->nd_lit);
+        VALUE str = rb_fstring(node->nd_lit);
 	ADD_INSN1(ret, line, putobject, str);
         RB_OBJ_WRITTEN(iseq, Qundef, str);
 	ADD_CALL(ret, line, idBackquote, INT2FIX(1));
@@ -8236,7 +8230,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in https://github.com/ruby/ruby/blob/trunk/compile.c#L8230
             !ISEQ_COMPILE_DATA(iseq)->option->frozen_string_literal &&
 	    ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction)
 	{
-	    VALUE str = freeze_literal(iseq, node->nd_args->nd_head->nd_lit);
+	    VALUE str = rb_fstring(node->nd_args->nd_head->nd_lit);
 	    CHECK(COMPILE(ret, "recv", node->nd_recv));
 	    CHECK(COMPILE(ret, "value", node->nd_args->nd_next->nd_head));
 	    if (!popped) {
-- 
cgit v0.10.2


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

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