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

ruby-changes:31118

From: nobu <ko1@a...>
Date: Tue, 8 Oct 2013 16:11:23 +0900 (JST)
Subject: [ruby-changes:31118] nobu:r43197 (trunk): array.c: use rb_hash_values

nobu	2013-10-08 16:11:15 +0900 (Tue, 08 Oct 2013)

  New Revision: 43197

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43197

  Log:
    array.c: use rb_hash_values
    
    * array.c (rb_ary_uniq): use rb_hash_values(), as well as the case no
      block is given.
    * internal.h: define rb_hash_values() as internal API.

  Modified files:
    trunk/ChangeLog
    trunk/array.c
    trunk/hash.c
    trunk/internal.h
Index: array.c
===================================================================
--- array.c	(revision 43196)
+++ array.c	(revision 43197)
@@ -4124,8 +4124,7 @@ rb_ary_uniq(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L4124
         return rb_ary_dup(ary);
     if (rb_block_given_p()) {
 	hash = ary_make_hash_by(ary);
-	uniq = ary_new(rb_obj_class(ary), RHASH_SIZE(hash));
-	st_foreach(rb_hash_tbl_raw(hash), push_value, uniq);
+	uniq = rb_hash_values(hash);
     }
     else {
 	hash = ary_make_hash(ary);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43196)
+++ ChangeLog	(revision 43197)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Oct  8 16:11:11 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* array.c (rb_ary_uniq): use rb_hash_values(), as well as the case no
+	  block is given.
+
+	* internal.h: define rb_hash_values() as internal API.
+
 Tue Oct  8 13:53:21 2013  Masaki Matsushita  <glass.saga@g...>
 
 	* array.c (rb_ary_uniq): use rb_hash_keys().
Index: hash.c
===================================================================
--- hash.c	(revision 43196)
+++ hash.c	(revision 43197)
@@ -1712,7 +1712,7 @@ values_i(VALUE key, VALUE value, VALUE a https://github.com/ruby/ruby/blob/trunk/hash.c#L1712
  *
  */
 
-static VALUE
+VALUE
 rb_hash_values(VALUE hash)
 {
     VALUE ary;
Index: internal.h
===================================================================
--- internal.h	(revision 43196)
+++ internal.h	(revision 43197)
@@ -436,6 +436,7 @@ void rb_gc_writebarrier_remember_promote https://github.com/ruby/ruby/blob/trunk/internal.h#L436
 struct st_table *rb_hash_tbl_raw(VALUE hash);
 #define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h)
 VALUE rb_hash_keys(VALUE hash);
+VALUE rb_hash_values(VALUE hash);
 
 /* inits.c */
 void rb_call_inits(void);

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

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