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

ruby-changes:6630

From: nobu <ko1@a...>
Date: Tue, 22 Jul 2008 02:52:06 +0900 (JST)
Subject: [ruby-changes:6630] Ruby:r18146 (trunk): * include/ruby/intern.h (rb_str_buf_cat2, rb_str_cat2): optimization

nobu	2008-07-22 02:51:49 +0900 (Tue, 22 Jul 2008)

  New Revision: 18146

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

  Log:
    * include/ruby/intern.h (rb_str_buf_cat2, rb_str_cat2): optimization
      for literals.

  Modified files:
    trunk/ChangeLog
    trunk/include/ruby/intern.h
    trunk/string.c

Index: include/ruby/intern.h
===================================================================
--- include/ruby/intern.h	(revision 18145)
+++ include/ruby/intern.h	(revision 18146)
@@ -537,26 +537,6 @@
 VALUE rb_str_tmp_new(long);
 VALUE rb_usascii_str_new(const char*, long);
 VALUE rb_usascii_str_new2(const char*);
-#if defined __GNUC__
-#define rb_str_new2(str) __extension__ (	\
-{						\
-    (__builtin_constant_p(str)) ?	       \
-	rb_str_new(str, strlen(str)) :		\
-	rb_str_new2(str);			\
-})
-#define rb_tainted_str_new2(str) __extension__ ( \
-{					       \
-    (__builtin_constant_p(str)) ?	       \
-	rb_tainted_str_new(str, strlen(str)) : \
-	rb_tainted_str_new2(str);	       \
-})
-#define rb_usascii_str_new2(str) __extension__ ( \
-{					       \
-    (__builtin_constant_p(str)) ?	       \
-	rb_usascii_str_new(str, strlen(str)) : \
-	rb_usascii_str_new2(str);	       \
-})
-#endif
 void rb_str_free(VALUE);
 void rb_str_shared_replace(VALUE, VALUE);
 VALUE rb_str_buf_append(VALUE, VALUE);
@@ -598,6 +578,38 @@
 VALUE rb_str_intern(VALUE);
 VALUE rb_sym_to_s(VALUE);
 VALUE rb_str_length(VALUE);
+#if defined __GNUC__
+#define rb_str_new2(str) __extension__ (	\
+{						\
+    (__builtin_constant_p(str)) ?		\
+	rb_str_new(str, strlen(str)) :		\
+	rb_str_new2(str);			\
+})
+#define rb_tainted_str_new2(str) __extension__ ( \
+{					       \
+    (__builtin_constant_p(str)) ?	       \
+	rb_tainted_str_new(str, strlen(str)) : \
+	rb_tainted_str_new2(str);	       \
+})
+#define rb_usascii_str_new2(str) __extension__ ( \
+{					       \
+    (__builtin_constant_p(str)) ?	       \
+	rb_usascii_str_new(str, strlen(str)) : \
+	rb_usascii_str_new2(str);	       \
+})
+#define rb_str_buf_cat2(str, ptr) __extension__ ( \
+{						\
+    (__builtin_constant_p(ptr)) ?	        \
+	rb_str_buf_cat(str, ptr, strlen(ptr)) :	\
+	rb_str_buf_cat2(str, ptr);		\
+})
+#define rb_str_cat2(str, ptr) __extension__ (	\
+{						\
+    (__builtin_constant_p(ptr)) ?	        \
+	rb_str_cat(str, ptr, strlen(ptr)) :	\
+	rb_str_cat2(str, ptr);			\
+})
+#endif
 /* struct.c */
 VALUE rb_struct_new(VALUE, ...);
 VALUE rb_struct_define(const char*, ...);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 18145)
+++ ChangeLog	(revision 18146)
@@ -1,3 +1,8 @@
+Tue Jul 22 02:51:46 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* include/ruby/intern.h (rb_str_buf_cat2, rb_str_cat2): optimization
+	  for literals.
+
 Tue Jul 22 02:50:47 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* README.EXT, README.EXT.ja (1.5 Manipulating Ruby data): fix the
Index: string.c
===================================================================
--- string.c	(revision 18145)
+++ string.c	(revision 18146)
@@ -28,6 +28,8 @@
 #undef rb_str_new2
 #undef rb_tainted_str_new2
 #undef rb_usascii_str_new2
+#undef rb_str_buf_cat2
+#undef rb_str_cat2
 
 VALUE rb_cString;
 VALUE rb_cSymbol;

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

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