summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--include/ruby/intern.h5
-rw-r--r--string.c4
3 files changed, 15 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 8141b69ccf..024da2c587 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Fri Jun 27 13:18:52 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * include/ruby/intern.h (rb_str_new2, rb_tainted_str_new2,
+ rb_usascii_str_new2): use with-length versions with strlen to
+ optimize strlen.
+
Fri Jun 27 12:28:57 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/un.rb (mkmf): new command to create makefile.
diff --git a/include/ruby/intern.h b/include/ruby/intern.h
index 36ae8442bb..f6a72b44d0 100644
--- a/include/ruby/intern.h
+++ b/include/ruby/intern.h
@@ -535,6 +535,11 @@ 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*);
+#ifdef __GNUC__
+#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));})
+#endif
void rb_str_free(VALUE);
void rb_str_shared_replace(VALUE, VALUE);
VALUE rb_str_buf_append(VALUE, VALUE);
diff --git a/string.c b/string.c
index 7877e64a98..4746842f5c 100644
--- a/string.c
+++ b/string.c
@@ -25,6 +25,10 @@
#include <unistd.h>
#endif
+#undef rb_str_new2
+#undef rb_tainted_str_new2
+#undef rb_usascii_str_new2
+
VALUE rb_cString;
VALUE rb_cSymbol;