ruby-changes:62016
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 29 Jun 2020 11:07:34 +0900 (JST)
Subject: [ruby-changes:62016] e3d821a36c (master): rb_str_crypt: do not goto into a branch
https://git.ruby-lang.org/ruby.git/commit/?id=e3d821a36c From e3d821a36ce9040542bb3fb8e1fa97df3fd06499 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: Thu, 18 Jun 2020 16:52:17 +0900 Subject: rb_str_crypt: 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/string.c b/string.c index 60ee2a5..c74e8eb 100644 --- a/string.c +++ b/string.c @@ -9645,8 +9645,7 @@ rb_str_crypt(VALUE str, VALUE salt) https://github.com/ruby/ruby/blob/trunk/string.c#L9645 mustnot_wchar(str); mustnot_wchar(salt); if (RSTRING_LEN(salt) < 2) { - short_salt: - rb_raise(rb_eArgError, "salt too short (need >=2 bytes)"); + goto short_salt; } s = StringValueCStr(str); @@ -9677,6 +9676,9 @@ rb_str_crypt(VALUE str, VALUE salt) https://github.com/ruby/ruby/blob/trunk/string.c#L9676 result = rb_str_new_cstr(res); CRYPT_END(); return result; + + short_salt: + rb_raise(rb_eArgError, "salt too short (need >=2 bytes)"); } -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/