aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authorduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-09 11:13:45 +0000
committerduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-09 11:13:45 +0000
commitdfcc54ba1bc31e840f031d2d88dc83a830b7e463 (patch)
tree2139fdcd9b21cead1eef640c12a45f4186539b5d /string.c
parent91fbcb30adade7cd39ce8ffbb5387bd232d36c2e (diff)
downloadruby-dfcc54ba1bc31e840f031d2d88dc83a830b7e463.tar.gz
replace hand-written argument check by call to rb_scan_args in unicode_normalize_common
In string.c, replace hand-written argument count check by call to rb_scan_args. This allows to use rb_funcallv once, rather than using rb_funcall twice. Thanks to Hanmac (Hans Mackowiak) for the idea, see https://bugs.ruby-lang.org/issues/11078#note-7. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/string.c b/string.c
index 1ab89bda55..47389ba7d7 100644
--- a/string.c
+++ b/string.c
@@ -9592,17 +9592,14 @@ static VALUE
unicode_normalize_common(int argc, VALUE *argv, VALUE str, ID id)
{
static int UnicodeNormalizeRequired = 0;
+ VALUE argv2[2] = { str };
if (!UnicodeNormalizeRequired) {
rb_require("unicode_normalize/normalize.rb");
UnicodeNormalizeRequired = 1;
}
- if (argc==0)
- return rb_funcall(mUnicodeNormalize, id, 1, str);
- else if (argc==1)
- return rb_funcall(mUnicodeNormalize, id, 2, str, argv[0]);
- else
- rb_raise(rb_eArgError, "too many arguments to unicode normalization function");
+ rb_scan_args(argc, argv, "01", &argv2[1]);
+ return rb_funcallv(mUnicodeNormalize, id, argc+1, argv2);
}
/*