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

ruby-changes:42991

From: naruse <ko1@a...>
Date: Thu, 19 May 2016 00:17:35 +0900 (JST)
Subject: [ruby-changes:42991] naruse:r55065 (trunk): * re.c (reg_names_iter): specify capacify

naruse	2016-05-19 00:17:31 +0900 (Thu, 19 May 2016)

  New Revision: 55065

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55065

  Log:
    * re.c (reg_names_iter): specify capacify

  Modified files:
    trunk/ChangeLog
    trunk/re.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 55064)
+++ ChangeLog	(revision 55065)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu May 19 00:17:01 2016  NARUSE, Yui  <naruse@r...>
+
+	* re.c (reg_names_iter): specify capacify
+
 Wed May 18 21:29:59 2016  NAKAMURA Usaku  <usa@r...>
 
 	* thread.c (recursive_list_access): a object id may be a Bignum.  so,
Index: re.c
===================================================================
--- re.c	(revision 55064)
+++ re.c	(revision 55065)
@@ -780,8 +780,9 @@ reg_names_iter(const OnigUChar *name, co https://github.com/ruby/ruby/blob/trunk/re.c#L780
 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;
 }

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

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