summaryrefslogtreecommitdiffstats
path: root/include/ruby
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-28 12:15:55 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-28 12:15:55 +0000
commit436defcc87afef2a730847c1ca54649bbbda1dcd (patch)
tree9fb0bfec13d648b87c8e6961f63244d6a0541e33 /include/ruby
parent35a669fdf87a88a014cec1237b42979d89574049 (diff)
downloadruby-436defcc87afef2a730847c1ca54649bbbda1dcd.tar.gz
ruby-436defcc87afef2a730847c1ca54649bbbda1dcd.tar.xz
ruby-436defcc87afef2a730847c1ca54649bbbda1dcd.zip
* include/ruby/intern.h (rb_str_new2, rb_tainted_str_new2,
rb_usascii_str_new2): use inline versions only for constant literals. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@17634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include/ruby')
-rw-r--r--include/ruby/intern.h23
1 files changed, 19 insertions, 4 deletions
diff --git a/include/ruby/intern.h b/include/ruby/intern.h
index f109cf75e..734bdfa7a 100644
--- a/include/ruby/intern.h
+++ b/include/ruby/intern.h
@@ -535,10 +535,25 @@ 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 __GNUC__ >= 4 && defined __OPTIMIZE__ && __OPTIMIZE__
-#define rb_str_new2(str) ({const char *_s = (str); rb_str_new(_s, strlen(_s));})
-#define rb_tainted_str_new2(str) ({const char *_s = (str); rb_tainted_str_new(_s, strlen(_s));})
-#define rb_usascii_str_new2(str) ({const char *_s = (str); rb_usascii_str_new(_s, strlen(_s));})
+#if defined __GNUC__
+#define rb_str_new2(str) ( \
+{ \
+ (__builtin_constant_p(str)) ? \
+ rb_str_new(str, strlen(str)) : \
+ rb_str_new2(str); \
+})
+#define rb_tainted_str_new2(str) ( \
+{ \
+ (__builtin_constant_p(str)) ? \
+ rb_tainted_str_new(str, strlen(str)) : \
+ rb_tainted_str_new2(str); \
+})
+#define rb_usascii_str_new2(str) ( \
+{ \
+ (__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);