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

ruby-changes:62057

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

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

From 31a770ac4827b6c9404d9506d234c23fd00da0f4 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: Wed, 17 Jun 2020 14:49:16 +0900
Subject: rb_strftime_with_timespec: 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/strftime.c b/strftime.c
index 0a08035..f4180fd 100644
--- a/strftime.c
+++ b/strftime.c
@@ -266,8 +266,7 @@ rb_strftime_with_timespec(VALUE ftime, const char *format, size_t format_len, https://github.com/ruby/ruby/blob/trunk/strftime.c#L266
 	static const char ampm[][3] = { "AM", "PM", };
 
 	if (format == NULL || format_len == 0 || vtm == NULL) {
-	err:
-		return 0;
+                goto err;
 	}
 
 	if (enc &&
@@ -911,6 +910,9 @@ rb_strftime_with_timespec(VALUE ftime, const char *format, size_t format_len, https://github.com/ruby/ruby/blob/trunk/strftime.c#L910
 	rb_str_set_len(ftime, len);
 	rb_str_resize(ftime, len);
 	return ftime;
+
+err:
+        return 0;
 }
 
 static size_t
-- 
cgit v0.10.2


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

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