diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-07-21 17:51:49 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-07-21 17:51:49 +0000 |
commit | 6112c433b852aad6e9a6ed0839352c6d600b1b24 (patch) | |
tree | 483171c27db24cf45614a509768300b04a312ba8 | |
parent | 37ec3b72b7d40f5f4e1168e879176bbba72dbb78 (diff) | |
download | ruby-6112c433b852aad6e9a6ed0839352c6d600b1b24.tar.gz ruby-6112c433b852aad6e9a6ed0839352c6d600b1b24.tar.xz ruby-6112c433b852aad6e9a6ed0839352c6d600b1b24.zip |
* include/ruby/intern.h (rb_str_buf_cat2, rb_str_cat2): optimization
for literals.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | include/ruby/intern.h | 52 | ||||
-rw-r--r-- | string.c | 2 |
3 files changed, 39 insertions, 20 deletions
@@ -1,3 +1,8 @@ +Tue Jul 22 02:51:46 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * include/ruby/intern.h (rb_str_buf_cat2, rb_str_cat2): optimization + for literals. + Tue Jul 22 02:50:47 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> * README.EXT, README.EXT.ja (1.5 Manipulating Ruby data): fix the diff --git a/include/ruby/intern.h b/include/ruby/intern.h index b009384d9..29fa2c2a2 100644 --- a/include/ruby/intern.h +++ b/include/ruby/intern.h @@ -537,26 +537,6 @@ VALUE rb_str_buf_new2(const char*); 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 @@ void rb_str_setter(VALUE, ID, VALUE*); 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*, ...); @@ -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; |