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

ruby-changes:8208

From: nobu <ko1@a...>
Date: Fri, 10 Oct 2008 01:56:08 +0900 (JST)
Subject: [ruby-changes:8208] Ruby:r19736 (trunk): * encoding.c (enc_names): minor improvement.

nobu	2008-10-10 01:55:51 +0900 (Fri, 10 Oct 2008)

  New Revision: 19736

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

  Log:
    * encoding.c (enc_names): minor improvement.

  Modified files:
    trunk/ChangeLog
    trunk/encoding.c

Index: encoding.c
===================================================================
--- encoding.c	(revision 19735)
+++ encoding.c	(revision 19736)
@@ -824,12 +824,14 @@
 }
 
 static int
-enc_names_i(st_data_t name, st_data_t idx, st_data_t ary)
+enc_names_i(st_data_t name, st_data_t idx, st_data_t args)
 {
-    if ((int)idx == FIX2INT(rb_ary_entry(ary, 0))) {
+    VALUE *arg = (VALUE *)args;
+
+    if ((int)idx == (int)arg[0]) {
 	VALUE str = rb_usascii_str_new2((char *)name);
 	OBJ_FREEZE(str);
-	rb_ary_push(ary, str);
+	rb_ary_push(arg[1], str);
     }
     return ST_CONTINUE;
 }
@@ -845,11 +847,12 @@
 static VALUE
 enc_names(VALUE self)
 {
-    VALUE ary = rb_ary_new2(0);
-    rb_ary_push(ary, INT2FIX(rb_to_encoding_index(self)));
-    st_foreach(enc_table.names, enc_names_i, (st_data_t)ary);
-    rb_ary_shift(ary);
-    return ary;
+    VALUE args[2];
+
+    args[0] = (VALUE)rb_to_encoding_index(self);
+    args[1] = rb_ary_new2(0);
+    st_foreach(enc_table.names, enc_names_i, (st_data_t)args);
+    return args[1];
 }
 
 /*
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 19735)
+++ ChangeLog	(revision 19736)
@@ -1,3 +1,7 @@
+Fri Oct 10 01:55:48 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* encoding.c (enc_names): minor improvement.
+
 Fri Oct 10 00:21:39 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/optparse.rb (ParseError.filter_backtrace): removes internal

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

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