aboutsummaryrefslogtreecommitdiffstats
path: root/re.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-02 12:23:17 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-02 12:23:17 +0000
commitfdcac03d9e37a4b80f1c4edc20a5944a88421559 (patch)
tree10013564063d5a69c726d560dda969dc0861ed8b /re.c
parentecce6b524c28ba398105eac554d31a09e2474231 (diff)
downloadruby-fdcac03d9e37a4b80f1c4edc20a5944a88421559.tar.gz
use rb_hash_new_with_size()
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60101 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r--re.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/re.c b/re.c
index abdacb816d..c1c29aea37 100644
--- a/re.c
+++ b/re.c
@@ -820,9 +820,9 @@ reg_named_captures_iter(const OnigUChar *name, const OnigUChar *name_end,
static VALUE
rb_reg_named_captures(VALUE re)
{
- VALUE hash = rb_hash_new();
- rb_reg_check(re);
- onig_foreach_name(RREGEXP_PTR(re), reg_named_captures_iter, (void*)hash);
+ regex_t *reg = (rb_reg_check(re), RREGEXP_PTR(re));
+ VALUE hash = rb_hash_new_with_size(onig_number_of_names(reg));
+ onig_foreach_name(reg, reg_named_captures_iter, (void*)hash);
return hash;
}