From 98e65d9d921ec810bbae2233b80e865e76dd8502 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 6 Dec 2018 07:49:24 +0000 Subject: Prefer rb_check_arity when 0 or 1 arguments Especially over checking argc then calling rb_scan_args just to raise an ArgumentError. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- transcode.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'transcode.c') diff --git a/transcode.c b/transcode.c index 9462433130..5f9e4e9600 100644 --- a/transcode.c +++ b/transcode.c @@ -4115,10 +4115,9 @@ econv_putback(int argc, VALUE *argv, VALUE self) int putbackable; VALUE str, max; - rb_scan_args(argc, argv, "01", &max); - - if (NIL_P(max)) + if (!rb_check_arity(argc, 0, 1) || NIL_P(max = argv[0])) { n = rb_econv_putbackable(ec); + } else { n = NUM2INT(max); putbackable = rb_econv_putbackable(ec); -- cgit v1.2.3