ruby-changes:49534
From: nobu <ko1@a...>
Date: Sun, 7 Jan 2018 13:57:09 +0900 (JST)
Subject: [ruby-changes:49534] nobu:r61649 (trunk): eval_error.c: concat directly
nobu 2018-01-07 13:57:04 +0900 (Sun, 07 Jan 2018) New Revision: 61649 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61649 Log: eval_error.c: concat directly * eval_error.c (write_warn, write_warn2): get rid of unnecessary intermediate string objects, concat directly. Modified files: trunk/eval_error.c Index: eval_error.c =================================================================== --- eval_error.c (revision 61648) +++ eval_error.c (revision 61649) @@ -3,26 +3,20 @@ https://github.com/ruby/ruby/blob/trunk/eval_error.c#L3 * 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)) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/