summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-06-18 16:52:17 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2020-06-29 11:05:41 +0900
commite3d821a36ce9040542bb3fb8e1fa97df3fd06499 (patch)
treeec821f02b56812c0be7ffe34bdf4ca4ae8d28aaa /string.c
parenta5ae9aebbc3d373d664747e5bfac5f47d3ac4102 (diff)
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.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3247
Diffstat (limited to 'string.c')
-rw-r--r--string.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/string.c b/string.c
index 60ee2a5fa3..c74e8ebbb7 100644
--- a/string.c
+++ b/string.c
@@ -9645,8 +9645,7 @@ rb_str_crypt(VALUE str, VALUE salt)
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)
result = rb_str_new_cstr(res);
CRYPT_END();
return result;
+
+ short_salt:
+ rb_raise(rb_eArgError, "salt too short (need >=2 bytes)");
}