aboutsummaryrefslogtreecommitdiffstats
path: root/re.c
diff options
context:
space:
mode:
Diffstat (limited to 're.c')
-rw-r--r--re.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/re.c b/re.c
index 7dfd978b66..36c12a6f6b 100644
--- a/re.c
+++ b/re.c
@@ -780,8 +780,9 @@ reg_names_iter(const OnigUChar *name, const OnigUChar *name_end,
static VALUE
rb_reg_names(VALUE re)
{
- VALUE ary = rb_ary_new();
+ VALUE ary;
rb_reg_check(re);
+ ary = rb_ary_new_capa(onig_number_of_names(RREGEXP_PTR(re)));
onig_foreach_name(RREGEXP_PTR(re), reg_names_iter, (void*)ary);
return ary;
}