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

ruby-changes:62048

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 29 Jun 2020 11:08:23 +0900 (JST)
Subject: [ruby-changes:62048] 2071c61e42 (master): tracepoint_inspect: do not goto into a branch

https://git.ruby-lang.org/ruby.git/commit/?id=2071c61e42

From 2071c61e4216b5de347b327acd60fa1b4affeec2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?=
 <shyouhei@r...>
Date: Mon, 22 Jun 2020 12:28:30 +0900
Subject: tracepoint_inspect: do not goto into a branch

I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea.  Better refactor.

diff --git a/vm_trace.c b/vm_trace.c
index 920a8d5..c02ad87 100644
--- a/vm_trace.c
+++ b/vm_trace.c
@@ -1455,7 +1455,7 @@ tracepoint_inspect(rb_execution_context_t *ec, VALUE self) https://github.com/ruby/ruby/blob/trunk/vm_trace.c#L1455
 	    {
 		VALUE sym = rb_tracearg_method_id(trace_arg);
 		if (NIL_P(sym))
-		    goto default_inspect;
+                    break;
 		return rb_sprintf("#<TracePoint:%"PRIsVALUE"@%"PRIsVALUE":%d in `%"PRIsVALUE"'>",
 				  rb_tracearg_event(trace_arg),
 				  rb_tracearg_path(trace_arg),
@@ -1477,12 +1477,12 @@ tracepoint_inspect(rb_execution_context_t *ec, VALUE self) https://github.com/ruby/ruby/blob/trunk/vm_trace.c#L1477
 			      rb_tracearg_event(trace_arg),
 			      rb_tracearg_self(trace_arg));
 	  default:
-	  default_inspect:
-	    return rb_sprintf("#<TracePoint:%"PRIsVALUE"@%"PRIsVALUE":%d>",
-			      rb_tracearg_event(trace_arg),
-			      rb_tracearg_path(trace_arg),
-			      FIX2INT(rb_tracearg_lineno(trace_arg)));
+            break;
 	}
+        return rb_sprintf("#<TracePoint:%"PRIsVALUE"@%"PRIsVALUE":%d>",
+                          rb_tracearg_event(trace_arg),
+                          rb_tracearg_path(trace_arg),
+                          FIX2INT(rb_tracearg_lineno(trace_arg)));
     }
     else {
 	return rb_sprintf("#<TracePoint:%s>", tp->tracing ? "enabled" : "disabled");
-- 
cgit v0.10.2


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

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