aboutsummaryrefslogtreecommitdiffstats
path: root/eval_error.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-07 04:57:04 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-07 04:57:04 +0000
commitac4d348d458defd030c548f608e0b0882a9c705a (patch)
treebae4a70e1dad31535ffcd45a56984f24c12db7d7 /eval_error.c
parent51501137b173f66e3db6bd53f43ba8d87db36a4e (diff)
downloadruby-ac4d348d458defd030c548f608e0b0882a9c705a.tar.gz
eval_error.c: concat directly
* eval_error.c (write_warn, write_warn2): get rid of unnecessary intermediate string objects, concat directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval_error.c')
-rw-r--r--eval_error.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/eval_error.c b/eval_error.c
index b6e0b99bd9..4b7e761742 100644
--- a/eval_error.c
+++ b/eval_error.c
@@ -3,26 +3,20 @@
* included by eval.c
*/
+#define write_warn(str, x) \
+ (NIL_P(str) ? warn_print(x) : (void)rb_str_cat_cstr(str, x))
+#define write_warn2(str, x, l) \
+ (NIL_P(str) ? warn_print2(x, l) : (void)rb_str_cat(str, x, l))
#ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
-#define write_warn(str, x) RB_GNUC_EXTENSION_BLOCK( \
- NIL_P(str) ? \
- warn_print(x) : (void)( \
- (__builtin_constant_p(x)) ? \
- rb_str_concat((str), rb_str_new((x), (long)strlen(x))) : \
- rb_str_concat((str), rb_str_new2(x)) \
- ) \
- )
#define warn_print(x) RB_GNUC_EXTENSION_BLOCK( \
(__builtin_constant_p(x)) ? \
rb_write_error2((x), (long)strlen(x)) : \
rb_write_error(x) \
)
#else
-#define write_warn(str, x) NIL_P(str) ? rb_write_error((x)) : (void)rb_str_concat((str), rb_str_new2(x))
#define warn_print(x) rb_write_error(x)
#endif
-#define write_warn2(str,x,l) NIL_P(str) ? warn_print2(x,l) : (void)rb_str_concat((str), rb_str_new((x),(l)))
#define warn_print2(x,l) rb_write_error2((x),(l))
#define write_warn_str(str,x) NIL_P(str) ? rb_write_error_str(x) : (void)rb_str_concat((str), (x))