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

ruby-changes:62078

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

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

From fd0e93588675982832ee075d11d9953aca97407e 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: Fri, 19 Jun 2020 12:59:31 +0900
Subject: time_mload: 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/time.c b/time.c
index f07eddb..457fac9 100644
--- a/time.c
+++ b/time.c
@@ -5328,8 +5328,7 @@ time_mload(VALUE time, VALUE str) https://github.com/ruby/ruby/blob/trunk/time.c#L5328
     StringValue(str);
     buf = (unsigned char *)RSTRING_PTR(str);
     if (RSTRING_LEN(str) < base_dump_size) {
-      invalid_format:
-	rb_raise(rb_eTypeError, "marshaled time format differ");
+        goto invalid_format;
     }
 
     p = s = 0;
@@ -5432,6 +5431,9 @@ end_submicro: ; https://github.com/ruby/ruby/blob/trunk/time.c#L5431
     }
 
     return time;
+
+  invalid_format:
+    rb_raise(rb_eTypeError, "marshaled time format differ");
 }
 
 /* :nodoc: */
-- 
cgit v0.10.2


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

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