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

ruby-changes:56467

From: Yusuke <ko1@a...>
Date: Sun, 14 Jul 2019 17:16:38 +0900 (JST)
Subject: [ruby-changes:56467] Yusuke Endoh: 934e6b2aeb (master): Prefer `rb_error_arity` to `rb_check_arity` when it can be used

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

From 934e6b2aeb495686f7fe0d8b1c69d863e6fca072 Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Sun, 14 Jul 2019 17:15:44 +0900
Subject: Prefer `rb_error_arity` to `rb_check_arity` when it can be used


diff --git a/eval.c b/eval.c
index fa3ec22..75648f1 100644
--- a/eval.c
+++ b/eval.c
@@ -790,8 +790,7 @@ make_exception(int argc, const VALUE *argv, int isstr) https://github.com/ruby/ruby/blob/trunk/eval.c#L790
 	}
 	break;
       default:
-	rb_check_arity(argc, 0, 3);
-	break;
+	rb_error_arity(argc, 0, 3);
     }
     if (argc > 0) {
 	if (!rb_obj_is_kind_of(mesg, rb_eException))
diff --git a/file.c b/file.c
index 50d1765..15970cb 100644
--- a/file.c
+++ b/file.c
@@ -3219,15 +3219,16 @@ rb_file_s_umask(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/file.c#L3219
 {
     mode_t omask = 0;
 
-    if (argc == 0) {
+    switch (argc) {
+      case 0:
 	omask = umask(0);
 	umask(omask);
-    }
-    else if (argc == 1) {
+        break;
+      case 1:
 	omask = umask(NUM2MODET(argv[0]));
-    }
-    else {
-	rb_check_arity(argc, 0, 1);
+        break;
+      default:
+	rb_error_arity(argc, 0, 1);
     }
     return MODET2NUM(omask);
 }
diff --git a/numeric.c b/numeric.c
index 1fce19a..90eabc2 100644
--- a/numeric.c
+++ b/numeric.c
@@ -3418,8 +3418,7 @@ int_chr(int argc, VALUE *argv, VALUE num) https://github.com/ruby/ruby/blob/trunk/numeric.c#L3418
       case 1:
 	break;
       default:
-	rb_check_arity(argc, 0, 1);
-	break;
+	rb_error_arity(argc, 0, 1);
     }
     enc = rb_to_encoding(argv[0]);
     if (!enc) enc = rb_ascii8bit_encoding();
diff --git a/string.c b/string.c
index 8d7d2ad..f76a417 100644
--- a/string.c
+++ b/string.c
@@ -5186,7 +5186,7 @@ str_gsub(int argc, VALUE *argv, VALUE str, int bang) https://github.com/ruby/ruby/blob/trunk/string.c#L5186
 	tainted = OBJ_TAINTED_RAW(repl);
 	break;
       default:
-	rb_check_arity(argc, 1, 2);
+	rb_error_arity(argc, 1, 2);
     }
 
     pat = get_pat_quoted(argv[0], 1);
-- 
cgit v0.10.2


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

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