diff options
author | Stefan Stùˆben <[email protected]> | 2020-09-25 19:56:30 +0200 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2020-10-21 12:45:18 +0900 |
commit | 8c2e5bbf58e562ea410b53c2f77e4186d5ca9da3 (patch) | |
tree | 974a704790a7500e83e5064e63d3cff191395386 | |
parent | d497436d07bc02989d6af284011193d18f7b8368 (diff) |
Don't redefine #rb_intern over and over again
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3589
-rw-r--r-- | array.c | 3 | ||||
-rw-r--r-- | compar.c | 3 | ||||
-rw-r--r-- | compile.c | 32 | ||||
-rw-r--r-- | complex.c | 25 | ||||
-rw-r--r-- | encoding.c | 2 | ||||
-rw-r--r-- | enum.c | 5 | ||||
-rw-r--r-- | ext/date/date_core.c | 11 | ||||
-rw-r--r-- | ext/openssl/ossl_ssl.c | 66 | ||||
-rw-r--r-- | ext/racc/cparse/cparse.c | 28 | ||||
-rw-r--r-- | hash.c | 8 | ||||
-rw-r--r-- | io.c | 59 | ||||
-rw-r--r-- | load.c | 6 | ||||
-rw-r--r-- | marshal.c | 3 | ||||
-rw-r--r-- | numeric.c | 9 | ||||
-rw-r--r-- | object.c | 3 | ||||
-rw-r--r-- | process.c | 64 | ||||
-rw-r--r-- | range.c | 9 | ||||
-rw-r--r-- | rational.c | 11 | ||||
-rw-r--r-- | string.c | 15 | ||||
-rw-r--r-- | template/id.c.tmpl | 2 | ||||
-rw-r--r-- | thread.c | 11 | ||||
-rw-r--r-- | time.c | 43 | ||||
-rw-r--r-- | vm_method.c | 3 |
23 files changed, 180 insertions, 241 deletions
@@ -8018,9 +8018,6 @@ rb_ary_deconstruct(VALUE ary) void Init_Array(void) { -#undef rb_intern -#define rb_intern(str) rb_intern_const(str) - rb_cArray = rb_define_class("Array", rb_cObject); rb_include_module(rb_cArray, rb_mEnumerable); @@ -294,9 +294,6 @@ cmp_clamp(int argc, VALUE *argv, VALUE x) void Init_Comparable(void) { -#undef rb_intern -#define rb_intern(str) rb_intern_const(str) - rb_mComparable = rb_define_module("Comparable"); rb_define_method(rb_mComparable, "==", cmp_equal, 1); rb_define_method(rb_mComparable, ">", cmp_gt, 1); @@ -9134,18 +9134,16 @@ register_label(rb_iseq_t *iseq, struct st_table *labels_table, VALUE obj) static VALUE get_exception_sym2type(VALUE sym) { -#undef rb_intern -#define rb_intern(str) rb_intern_const(str) static VALUE symRescue, symEnsure, symRetry; static VALUE symBreak, symRedo, symNext; if (symRescue == 0) { - symRescue = ID2SYM(rb_intern("rescue")); - symEnsure = ID2SYM(rb_intern("ensure")); - symRetry = ID2SYM(rb_intern("retry")); - symBreak = ID2SYM(rb_intern("break")); - symRedo = ID2SYM(rb_intern("redo")); - symNext = ID2SYM(rb_intern("next")); + symRescue = ID2SYM(rb_intern_const("rescue")); + symEnsure = ID2SYM(rb_intern_const("ensure")); + symRetry = ID2SYM(rb_intern_const("retry")); + symBreak = ID2SYM(rb_intern_const("break")); + symRedo = ID2SYM(rb_intern_const("redo")); + symNext = ID2SYM(rb_intern_const("next")); } if (sym == symRescue) return CATCH_TYPE_RESCUE; @@ -9211,7 +9209,7 @@ insn_make_insn_table(void) table = st_init_numtable_with_size(VM_INSTRUCTION_SIZE); for (i=0; i<VM_INSTRUCTION_SIZE; i++) { - st_insert(table, ID2SYM(rb_intern(insn_name(i))), i); + st_insert(table, ID2SYM(rb_intern_const(insn_name(i))), i); } return table; @@ -9246,10 +9244,10 @@ iseq_build_callinfo_from_hash(rb_iseq_t *iseq, VALUE op) struct rb_callinfo_kwarg *kw_arg = 0; if (!NIL_P(op)) { - VALUE vmid = rb_hash_aref(op, ID2SYM(rb_intern("mid"))); - VALUE vflag = rb_hash_aref(op, ID2SYM(rb_intern("flag"))); - VALUE vorig_argc = rb_hash_aref(op, ID2SYM(rb_intern("orig_argc"))); - VALUE vkw_arg = rb_hash_aref(op, ID2SYM(rb_intern("kw_arg"))); + VALUE vmid = rb_hash_aref(op, ID2SYM(rb_intern_const("mid"))); + VALUE vflag = rb_hash_aref(op, ID2SYM(rb_intern_const("flag"))); + VALUE vorig_argc = rb_hash_aref(op, ID2SYM(rb_intern_const("orig_argc"))); + VALUE vkw_arg = rb_hash_aref(op, ID2SYM(rb_intern_const("kw_arg"))); if (!NIL_P(vmid)) mid = SYM2ID(vmid); if (!NIL_P(vflag)) flag = NUM2UINT(vflag); @@ -9278,7 +9276,7 @@ iseq_build_callinfo_from_hash(rb_iseq_t *iseq, VALUE op) static rb_event_flag_t event_name_to_flag(VALUE sym) { -#define CHECK_EVENT(ev) if (sym == ID2SYM(rb_intern(#ev))) return ev; +#define CHECK_EVENT(ev) if (sym == ID2SYM(rb_intern_const(#ev))) return ev; CHECK_EVENT(RUBY_EVENT_LINE); CHECK_EVENT(RUBY_EVENT_CLASS); CHECK_EVENT(RUBY_EVENT_END); @@ -9483,7 +9481,7 @@ iseq_build_kw(rb_iseq_t *iseq, VALUE params, VALUE keywords) iseq->body->param.flags.has_kw = TRUE; keyword->num = len; -#define SYM(s) ID2SYM(rb_intern(#s)) +#define SYM(s) ID2SYM(rb_intern_const(#s)) (void)int_param(&keyword->bits_start, params, SYM(kwbits)); i = keyword->bits_start - keyword->num; ids = (ID *)&iseq->body->local_table[i]; @@ -9596,7 +9594,7 @@ void rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE misc, VALUE locals, VALUE params, VALUE exception, VALUE body) { -#define SYM(s) ID2SYM(rb_intern(#s)) +#define SYM(s) ID2SYM(rb_intern_const(#s)) int i, len; unsigned int arg_size, local_size, stack_max; ID *tbl; @@ -9604,7 +9602,7 @@ rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE misc, VALUE locals, VALUE params, VALUE labels_wrapper = Data_Wrap_Struct(0, rb_mark_set, st_free_table, labels_table); VALUE arg_opt_labels = rb_hash_aref(params, SYM(opt)); VALUE keywords = rb_hash_aref(params, SYM(keyword)); - VALUE sym_arg_rest = ID2SYM(rb_intern("#arg_rest")); + VALUE sym_arg_rest = ID2SYM(rb_intern_const("#arg_rest")); DECL_ANCHOR(anchor); INIT_ANCHOR(anchor); @@ -2337,20 +2337,17 @@ void Init_Complex(void) { VALUE compat; -#undef rb_intern -#define rb_intern(str) rb_intern_const(str) - - id_abs = rb_intern("abs"); - id_arg = rb_intern("arg"); - id_denominator = rb_intern("denominator"); - id_numerator = rb_intern("numerator"); - id_real_p = rb_intern("real?"); - id_i_real = rb_intern("@real"); - id_i_imag = rb_intern("@image"); /* @image, not @imag */ - id_finite_p = rb_intern("finite?"); - id_infinite_p = rb_intern("infinite?"); - id_rationalize = rb_intern("rationalize"); - id_PI = rb_intern("PI"); + id_abs = rb_intern_const("abs"); + id_arg = rb_intern_const("arg"); + id_denominator = rb_intern_const("denominator"); + id_numerator = rb_intern_const("numerator"); + id_real_p = rb_intern_const("real?"); + id_i_real = rb_intern_const("@real"); + id_i_imag = rb_intern_const("@image"); /* @image, not @imag */ + id_finite_p = rb_intern_const("finite?"); + id_infinite_p = rb_intern_const("infinite?"); + id_rationalize = rb_intern_const("rationalize"); + id_PI = rb_intern_const("PI"); rb_cComplex = rb_define_class("Complex", rb_cNumeric); diff --git a/encoding.c b/encoding.c index 7f798cd78d..7336421862 100644 --- a/encoding.c +++ b/encoding.c @@ -2145,8 +2145,6 @@ rb_enc_aliases(VALUE klass) void Init_Encoding(void) { -#undef rb_intern -#define rb_intern(str) rb_intern_const(str) VALUE list; int i; @@ -4172,9 +4172,6 @@ enum_uniq(VALUE obj) void Init_Enumerable(void) { -#undef rb_intern -#define rb_intern(str) rb_intern_const(str) - rb_mEnumerable = rb_define_module("Enumerable"); rb_define_method(rb_mEnumerable, "to_a", enum_to_a, -1); @@ -4236,5 +4233,5 @@ Init_Enumerable(void) rb_define_method(rb_mEnumerable, "sum", enum_sum, -1); rb_define_method(rb_mEnumerable, "uniq", enum_uniq, 0); - id_next = rb_intern("next"); + id_next = rb_intern_const("next"); } diff --git a/ext/date/date_core.c b/ext/date/date_core.c index f9567e23e8..bb0482c279 100644 --- a/ext/date/date_core.c +++ b/ext/date/date_core.c @@ -9116,13 +9116,10 @@ d_lite_zero(VALUE x) void Init_date_core(void) { -#undef rb_intern -#define rb_intern(str) rb_intern_const(str) - - id_cmp = rb_intern("<=>"); - id_le_p = rb_intern("<="); - id_ge_p = rb_intern(">="); - id_eqeq_p = rb_intern("=="); + id_cmp = rb_intern_const("<=>"); + id_le_p = rb_intern_const("<="); + id_ge_p = rb_intern_const(">="); + id_eqeq_p = rb_intern_const("=="); half_days_in_day = rb_rational_new2(INT2FIX(1), INT2FIX(2)); diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c index fe2e85b866..4b7efa39f5 100644 --- a/ext/openssl/ossl_ssl.c +++ b/ext/openssl/ossl_ssl.c @@ -2456,8 +2456,6 @@ ossl_ssl_tmp_key(VALUE self) # endif /* defined(HAVE_SSL_GET_SERVER_TMP_KEY) */ #endif /* !defined(OPENSSL_NO_SOCK) */ -#undef rb_intern -#define rb_intern(s) rb_intern_const(s) void Init_ossl_ssl(void) { @@ -2468,8 +2466,8 @@ Init_ossl_ssl(void) rb_mWaitWritable = rb_define_module_under(rb_cIO, "WaitWritable"); #endif - id_call = rb_intern("call"); - ID_callback_state = rb_intern("callback_state"); + id_call = rb_intern_const("call"); + ID_callback_state = rb_intern_const("callback_state"); ossl_ssl_ex_vcb_idx = SSL_get_ex_new_index(0, (void *)"ossl_ssl_ex_vcb_idx", 0, 0, 0); if (ossl_ssl_ex_vcb_idx < 0) @@ -2536,7 +2534,7 @@ Init_ossl_ssl(void) * The _cert_, _key_, and _extra_chain_cert_ attributes are deprecated. * It is recommended to use #add_certificate instead. */ - rb_attr(cSSLContext, rb_intern("cert"), 1, 1, Qfalse); + rb_attr(cSSLContext, rb_intern_const("cert"), 1, 1, Qfalse); /* * Context private key @@ -2544,29 +2542,29 @@ Init_ossl_ssl(void) * The _cert_, _key_, and _extra_chain_cert_ attributes are deprecated. * It is recommended to use #add_certificate instead. */ - rb_attr(cSSLContext, rb_intern("key"), 1, 1, Qfalse); + rb_attr(cSSLContext, rb_intern_const("key"), 1, 1, Qfalse); /* * A certificate or Array of certificates that will be sent to the client. */ - rb_attr(cSSLContext, rb_intern("client_ca"), 1, 1, Qfalse); + rb_attr(cSSLContext, rb_intern_const("client_ca"), 1, 1, Qfalse); /* * The path to a file containing a PEM-format CA certificate */ - rb_attr(cSSLContext, rb_intern("ca_file"), 1, 1, Qfalse); + rb_attr(cSSLContext, rb_intern_const("ca_file"), 1, 1, Qfalse); /* * The path to a directory containing CA certificates in PEM format. * * Files are looked up by subject's X509 name's hash value. */ - rb_attr(cSSLContext, rb_intern("ca_path"), 1, 1, Qfalse); + rb_attr(cSSLContext, rb_intern_const("ca_path"), 1, 1, Qfalse); /* * Maximum session lifetime in seconds. */ - rb_attr(cSSLContext, rb_intern("timeout"), 1, 1, Qfalse); + rb_attr(cSSLContext, rb_intern_const("timeout"), 1, 1, Qfalse); /* * Session verification mode. @@ -2579,12 +2577,12 @@ Init_ossl_ssl(void) * * See SSL_CTX_set_verify(3) for details. */ - rb_attr(cSSLContext, rb_intern("verify_mode"), 1, 1, Qfalse); + rb_attr(cSSLContext, rb_intern_const("verify_mode"), 1, 1, Qfalse); /* * Number of CA certificates to walk when verifying a certificate chain. */ - rb_attr(cSSLContext, rb_intern("verify_depth"), 1, 1, Qfalse); + rb_attr(cSSLContext, rb_intern_const("verify_depth"), 1, 1, Qfalse); /* * A callback for additional certificate verification. The callback is @@ -2598,7 +2596,7 @@ Init_ossl_ssl(void) * If the callback returns +false+, the chain verification is immediately * stopped and a bad_certificate alert is then sent. */ - rb_attr(cSSLContext, rb_intern("verify_callback"), 1, 1, Qfalse); + rb_attr(cSSLContext, rb_intern_const("verify_callback"), 1, 1, Qfalse); /* * Whether to check the server certificate is valid for the hostname. @@ -2606,12 +2604,12 @@ Init_ossl_ssl(void) * In order to make this work, verify_mode must be set to VERIFY_PEER and * the server hostname must be given by OpenSSL::SSL::SSLSocket#hostname=. */ - rb_attr(cSSLContext, rb_intern("verify_hostname"), 1, 1, Qfalse); + rb_attr(cSSLContext, rb_intern_const("verify_hostname"), 1, 1, Qfalse); /* * An OpenSSL::X509::Store used for certificate verification. */ - rb_attr(cSSLContext, rb_intern("cert_store"), 1, 1, Qfalse); + rb_attr(cSSLContext, rb_intern_const("cert_store"), 1, 1, Qfalse); /* * An Array of extra X509 certificates to be added to the certificate @@ -2620,7 +2618,7 @@ Init_ossl_ssl(void) * The _cert_, _key_, and _extra_chain_cert_ attributes are deprecated. * It is recommended to use #add_certificate instead. */ - rb_attr(cSSLContext, rb_intern("extra_chain_cert"), 1, 1, Qfalse); + rb_attr(cSSLContext, rb_intern_const("extra_chain_cert"), 1, 1, Qfalse); /* * A callback invoked when a client certificate is requested by a server @@ -2630,7 +2628,7 @@ Init_ossl_ssl(void) * containing an OpenSSL::X509::Certificate and an OpenSSL::PKey. If any * other value is returned the handshake is suspended. */ - rb_attr(cSSLContext, rb_intern("client_cert_cb"), 1, 1, Qfalse); + rb_attr(cSSLContext, rb_intern_const("client_cert_cb"), 1, 1, Qfalse); #if !defined(OPENSSL_NO_EC) && defined(HAVE_SSL_CTX_SET_TMP_ECDH_CALLBACK) /* @@ -2643,7 +2641,7 @@ Init_ossl_ssl(void) * The callback is deprecated. This does not work with recent versions of * OpenSSL. Use OpenSSL::SSL::SSLContext#ecdh_curves= instead. */ - rb_attr(cSSLContext, rb_intern("tmp_ecdh_callback"), 1, 1, Qfalse); + rb_attr(cSSLContext, rb_intern_const("tmp_ecdh_callback"), 1, 1, Qfalse); #endif /* @@ -2651,7 +2649,7 @@ Init_ossl_ssl(void) * sessions for multiple applications to be distinguished, for example, by * name. */ - rb_attr(cSSLContext, rb_intern("session_id_context"), 1, 1, Qfalse); + rb_attr(cSSLContext, rb_intern_const("session_id_context"), 1, 1, Qfalse); /* * A callback invoked on a server when a session is proposed by the client @@ -2660,7 +2658,7 @@ Init_ossl_ssl(void) * The callback is invoked with the SSLSocket and session id. The * callback may return a Session from an external cache. */ - rb_attr(cSSLContext, rb_intern("session_get_cb"), 1, 1, Qfalse); + rb_attr(cSSLContext, rb_intern_const("session_get_cb"), 1, 1, Qfalse); /* * A callback invoked when a new session was negotiated. @@ -2668,7 +2666,7 @@ Init_ossl_ssl(void) * The callback is invoked with an SSLSocket. If +false+ is returned the * session will be removed from the internal cache. */ - rb_attr(cSSLContext, rb_intern("session_new_cb"), 1, 1, Qfalse); + rb_attr(cSSLContext, rb_intern_const("session_new_cb"), 1, 1, Qfalse); /* * A callback invoked when a session is removed from the internal cache. @@ -2679,7 +2677,7 @@ Init_ossl_ssl(void) * multi-threaded application. The callback is called inside a global lock * and it can randomly cause deadlock on Ruby thread switching. */ - rb_attr(cSSLContext, rb_intern("session_remove_cb"), 1, 1, Qfalse); + rb_attr(cSSLContext, rb_intern_const("session_remove_cb"), 1, 1, Qfalse); rb_define_const(mSSLExtConfig, "HAVE_TLSEXT_HOST_NAME", Qtrue); @@ -2702,7 +2700,7 @@ Init_ossl_ssl(void) * raise RuntimeError, "Client renegotiation disabled" * end */ - rb_attr(cSSLContext, rb_intern("renegotiation_cb"), 1, 1, Qfalse); + rb_attr(cSSLContext, rb_intern_const("renegotiation_cb"), 1, 1, Qfalse); #ifndef OPENSSL_NO_NEXTPROTONEG /* * An Enumerable of Strings. Each String represents a protocol to be @@ -2715,7 +2713,7 @@ Init_ossl_ssl(void) * * ctx.npn_protocols = ["http/1.1", "spdy/2"] */ - rb_attr(cSSLContext, rb_intern("npn_protocols"), 1, 1, Qfalse); + rb_attr(cSSLContext, rb_intern_const("npn_protocols"), 1, 1, Qfalse); /* * A callback invoked on the client side when the client needs to select * a protocol from the list sent by the server. Supported in OpenSSL 1.0.1 @@ -2732,7 +2730,7 @@ Init_ossl_ssl(void) * protocols.first * end */ - rb_attr(cSSLContext, rb_intern("npn_select_cb"), 1, 1, Qfalse); + rb_attr(cSSLContext, rb_intern_const("npn_select_cb"), 1, 1, Qfalse); #endif #ifdef HAVE_SSL_CTX_SET_ALPN_SELECT_CB @@ -2747,7 +2745,7 @@ Init_ossl_ssl(void) * * ctx.alpn_protocols = ["http/1.1", "spdy/2", "h2"] */ - rb_attr(cSSLContext, rb_intern("alpn_protocols"), 1, 1, Qfalse); + rb_attr(cSSLContext, rb_intern_const("alpn_protocols"), 1, 1, Qfalse); /* * A callback invoked on the server side when the server needs to select * a protocol from the list sent by the client. Supported in OpenSSL 1.0.2 @@ -2764,7 +2762,7 @@ Init_ossl_ssl(void) * protocols.first * end */ - rb_attr(cSSLContext, rb_intern("alpn_select_cb"), 1, 1, Qfalse); + rb_attr(cSSLContext, rb_intern_const("alpn_select_cb"), 1, 1, Qfalse); #endif rb_define_alias(cSSLContext, "ssl_timeout", "timeout"); @@ -2992,16 +2990,16 @@ Init_ossl_ssl(void) #endif - sym_exception = ID2SYM(rb_intern("exception")); - sym_wait_readable = ID2SYM(rb_intern("wait_readable")); - sym_wait_writable = ID2SYM(rb_intern("wait_writable")); + sym_exception = ID2SYM(rb_intern_const("exception")); + sym_wait_readable = ID2SYM(rb_intern_const("wait_readable")); + sym_wait_writable = ID2SYM(rb_intern_const("wait_writable")); - id_tmp_dh_callback = rb_intern("tmp_dh_callback"); - id_tmp_ecdh_callback = rb_intern("tmp_ecdh_callback"); - id_npn_protocols_encoded = rb_intern("npn_protocols_encoded"); + id_tmp_dh_callback = rb_intern_const("tmp_dh_callback"); + id_tmp_ecdh_callback = rb_intern_const("tmp_ecdh_callback"); + id_npn_protocols_encoded = rb_intern_const("npn_protocols_encoded"); #define DefIVarID(name) do \ - id_i_##name = rb_intern("@"#name); while (0) + id_i_##name = rb_intern_const("@"#name); while (0) DefIVarID(cert_store); DefIVarID(ca_file); diff --git a/ext/racc/cparse/cparse.c b/ext/racc/cparse/cparse.c index 4d77bbf298..487784a149 100644 --- a/ext/racc/cparse/cparse.c +++ b/ext/racc/cparse/cparse.c @@ -819,14 +819,12 @@ reduce0(RB_BLOCK_CALL_FUNC_ARGLIST(_, data)) void Init_cparse(void) { -#undef rb_intern -#define rb_intern(str) rb_intern_const(str) VALUE Racc, Parser; ID id_racc = rb_intern("Racc"); if (rb_const_defined(rb_cObject, id_racc)) { Racc = rb_const_get(rb_cObject, id_racc); - Parser = rb_const_get_at(Racc, rb_intern("Parser")); + Parser = rb_const_get_at(Racc, rb_intern_const("Parser")); } else { Racc = rb_define_module("Racc"); @@ -846,16 +844,16 @@ Init_cparse(void) RaccBug = rb_eRuntimeError; - id_yydebug = rb_intern("@yydebug"); - id_nexttoken = rb_intern("next_token"); - id_onerror = rb_intern("on_error"); - id_noreduce = rb_intern("_reduce_none"); - id_errstatus = rb_intern("@racc_error_status"); - - id_d_shift = rb_intern("racc_shift"); - id_d_reduce = rb_intern("racc_reduce"); - id_d_accept = rb_intern("racc_accept"); - id_d_read_token = rb_intern("racc_read_token"); - id_d_next_state = rb_intern("racc_next_state"); - id_d_e_pop = rb_intern("racc_e_pop"); + id_yydebug = rb_intern_const("@yydebug"); + id_nexttoken = rb_intern_const("next_token"); + id_onerror = rb_intern_const("on_error"); + id_noreduce = rb_intern_const("_reduce_none"); + id_errstatus = rb_intern_const("@racc_error_status"); + + id_d_shift = rb_intern_const("racc_shift"); + id_d_reduce = rb_intern_const("racc_reduce"); + id_d_accept = rb_intern_const("racc_accept"); + id_d_read_token = rb_intern_const("racc_read_token"); + id_d_next_state = rb_intern_const("racc_next_state"); + id_d_e_pop = rb_intern_const("racc_e_pop"); } @@ -6913,11 +6913,9 @@ env_update(VALUE env, VALUE hash) void Init_Hash(void) { -#undef rb_intern -#define rb_intern(str) rb_intern_const(str) - id_hash = rb_intern("hash"); - id_default = rb_intern("default"); - id_flatten_bang = rb_intern("flatten!"); + id_hash = rb_intern_const("hash"); + id_default = rb_intern_const("default"); + id_flatten_bang = rb_intern_const("flatten!"); id_hash_iter_lev = rb_make_internal_id(); rb_cHash = rb_define_class("Hash", rb_cObject); @@ -13423,9 +13423,6 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y) void Init_IO(void) { -#undef rb_intern -#define rb_intern(str) rb_intern_const(str) - VALUE rb_cARGF; #ifdef __CYGWIN__ #include <sys/cygwin.h> @@ -13443,12 +13440,12 @@ Init_IO(void) rb_eIOError = rb_define_class("IOError", rb_eStandardError); rb_eEOFError = rb_define_class("EOFError", rb_eIOError); - id_write = rb_intern("write"); - id_read = rb_intern("read"); - id_getc = rb_intern("getc"); - id_flush = rb_intern("flush"); - id_readpartial = rb_intern("readpartial"); - id_set_encoding = rb_intern("set_encoding"); + id_write = rb_intern_const("write"); + id_read = rb_intern_const("read"); + id_getc = rb_intern_const("getc"); + id_flush = rb_intern_const("flush"); + id_readpartial = rb_intern_const("readpartial"); + id_set_encoding = rb_intern_const("set_encoding"); rb_define_global_function("syscall", rb_f_syscall, -1); @@ -13777,33 +13774,33 @@ Init_IO(void) rb_define_method(rb_cFile, "initialize", rb_file_initialize, -1); - sym_mode = ID2SYM(rb_intern("mode")); - sym_perm = ID2SYM(rb_intern("perm")); - sym_flags = ID2SYM(rb_intern("flags")); - sym_extenc = ID2SYM(rb_intern("external_encoding")); - sym_intenc = ID2SYM(rb_intern("internal_encoding")); + sym_mode = ID2SYM(rb_intern_const("mode")); + sym_perm = ID2SYM(rb_intern_const("perm")); + sym_flags = ID2SYM(rb_intern_const("flags")); + sym_extenc = ID2SYM(rb_intern_const("external_encoding")); + sym_intenc = ID2SYM(rb_intern_const("internal_encoding")); sym_encoding = ID2SYM(rb_id_encoding()); - sym_open_args = ID2SYM(rb_intern("open_args")); - sym_textmode = ID2SYM(rb_intern("textmode")); - sym_binmode = ID2SYM(rb_intern("binmode")); - sym_autoclose = ID2SYM(rb_intern("autoclose")); - sym_normal = ID2SYM(rb_intern("normal")); - sym_sequential = ID2SYM(rb_intern("sequential")); - sym_random = ID2SYM(rb_intern("random")); - sym_willneed = ID2SYM(rb_intern("willneed")); - sym_dontneed = ID2SYM(rb_intern("dontneed")); - sym_noreuse = ID2SYM(rb_intern("noreuse")); - sym_SET = ID2SYM(rb_intern("SET")); - sym_CUR = ID2SYM(rb_intern("CUR")); - sym_END = ID2SYM(rb_intern("END")); + sym_open_args = ID2SYM(rb_intern_const("open_args")); + sym_textmode = ID2SYM(rb_intern_const("textmode")); + sym_binmode = ID2SYM(rb_intern_const("binmode")); + sym_autoclose = ID2SYM(rb_intern_const("autoclose")); + sym_normal = ID2SYM(rb_intern_const("normal")); + sym_sequential = ID2SYM(rb_intern_const("sequential")); + sym_random = ID2SYM(rb_intern_const("random")); + sym_willneed = ID2SYM(rb_intern_const("willneed")); + sym_dontneed = ID2SYM(rb_intern_const("dontneed")); + sym_noreuse = ID2SYM(rb_intern_const("noreuse")); + sym_SET = ID2SYM(rb_intern_const("SET")); + sym_CUR = ID2SYM(rb_intern_const("CUR")); + sym_END = ID2SYM(rb_intern_const("END")); #ifdef SEEK_DATA - sym_DATA = ID2SYM(rb_intern("DATA")); + sym_DATA = ID2SYM(rb_intern_const("DATA")); #endif #ifdef SEEK_HOLE - sym_HOLE = ID2SYM(rb_intern("HOLE")); + sym_HOLE = ID2SYM(rb_intern_const("HOLE")); #endif - sym_wait_readable = ID2SYM(rb_intern("wait_readable")); - sym_wait_writable = ID2SYM(rb_intern("wait_writable")); + sym_wait_readable = ID2SYM(rb_intern_const("wait_readable")); + sym_wait_writable = ID2SYM(rb_intern_const("wait_writable")); } #include "io.rbinc" @@ -1265,15 +1265,13 @@ rb_f_autoload_p(int argc, VALUE *argv, VALUE obj) void Init_load(void) { -#undef rb_intern -#define rb_intern(str) rb_intern2((str), strlen(str)) rb_vm_t *vm = GET_VM(); static const char var_load_path[] = "$:"; ID id_load_path = rb_intern2(var_load_path, sizeof(var_load_path)-1); rb_define_hooked_variable(var_load_path, (VALUE*)vm, load_path_getter, rb_gvar_readonly_setter); - rb_alias_variable(rb_intern("$-I"), id_load_path); - rb_alias_variable(rb_intern("$LOAD_PATH"), id_load_path); + rb_alias_variable(rb_intern_const("$-I"), id_load_path); + rb_alias_variable(rb_intern_const("$LOAD_PATH"), id_load_path); vm->load_path = rb_ary_new(); vm->expanded_load_path = rb_ary_tmp_new(0); vm->load_path_snapshot = rb_ary_tmp_new(0); @@ -2323,9 +2323,6 @@ rb_marshal_load_with_proc(VALUE port, VALUE proc) void Init_marshal(void) { -#undef rb_intern -#define rb_intern(str) rb_intern_const(str) - VALUE rb_mMarshal = rb_define_module("Marshal"); #define set_id(sym) sym = rb_intern_const(name_##sym) set_id(s_dump); @@ -5542,16 +5542,13 @@ rb_int_s_isqrt(VALUE self, VALUE num) void Init_Numeric(void) { -#undef rb_intern -#define rb_intern(str) rb_intern_const(str) - #ifdef _UNICOSMP /* Turn off floating point exceptions for divide by zero, etc. */ _set_Creg(0, 0); #endif - id_coerce = rb_intern("coerce"); - id_to = rb_intern("to"); - id_by = rb_intern("by"); + id_coerce = rb_intern_const("coerce"); + id_to = rb_intern_const("to"); + id_by = rb_intern_const("by"); rb_eZeroDivError = rb_define_class("ZeroDivisionError", rb_eStandardError); rb_eFloatDomainError = rb_define_class("FloatDomainError", rb_eRangeError); @@ -4479,9 +4479,6 @@ InitVM_Object(void) rb_cClass = rb_define_class("Class", rb_cModule); #endif -#undef rb_intern -#define rb_intern(str) rb_intern_const(str) - rb_define_private_method(rb_cBasicObject, "initialize", rb_obj_dummy0, 0); rb_define_alloc_func(rb_cBasicObject, rb_class_allocate_instance); rb_define_method(rb_cBasicObject, "==", rb_obj_equal, 1); @@ -8441,8 +8441,6 @@ static VALUE rb_mProcID_Syscall; void InitVM_process(void) { -#undef rb_intern -#define rb_intern(str) rb_intern_const(str) rb_define_virtual_variable("$?", get_CHILD_STATUS, 0); rb_define_virtual_variable("$$", get_PROCESS_ID, 0); @@ -8872,46 +8870,46 @@ InitVM_process(void) void Init_process(void) { - id_in = rb_intern("in"); - id_out = rb_intern("out"); - id_err = rb_intern("err"); - id_pid = rb_intern("pid"); - id_uid = rb_intern("uid"); - id_gid = rb_intern("gid"); - id_close = rb_intern("close"); - id_child = rb_intern("child"); + id_in = rb_intern_const("in"); + id_out = rb_intern_const("out"); + id_err = rb_intern_const("err"); + id_pid = rb_intern_const("pid"); + id_uid = rb_intern_const("uid"); + id_gid = rb_intern_const("gid"); + id_close = rb_intern_const("close"); + id_child = rb_intern_const("child"); #ifdef HAVE_SETPGID - id_pgroup = rb_intern("pgroup"); + id_pgroup = rb_intern_const("pgroup"); #endif #ifdef _WIN32 - id_new_pgroup = rb_intern("new_pgroup"); -#endif - id_unsetenv_others = rb_intern("unsetenv_others"); - id_chdir = rb_intern("chdir"); - id_umask = rb_intern("umask"); - id_close_others = rb_intern("close_others"); - id_ENV = rb_intern("ENV"); - id_nanosecond = rb_intern("nanosecond"); - id_microsecond = rb_intern("microsecond"); - id_millisecond = rb_intern("millisecond"); - id_second = rb_intern("second"); - id_float_microsecond = rb_intern("float_microsecond"); - id_float_millisecond = rb_intern("float_millisecond"); - id_float_second = rb_intern("float_second"); - id_GETTIMEOFDAY_BASED_CLOCK_REALTIME = rb_intern("GETTIMEOFDAY_BASED_CLOCK_REALTIME"); - id_TIME_BASED_CLOCK_REALTIME = rb_intern("TIME_BASED_CLOCK_REALTIME"); + id_new_pgroup = rb_intern_const("new_pgroup"); +#endif + id_unsetenv_others = rb_intern_const("unsetenv_others"); + id_chdir = rb_intern_const("chdir"); + id_umask = rb_intern_const("umask"); + id_close_others = rb_intern_const("close_others"); + id_ENV = rb_intern_const("ENV"); + id_nanosecond = rb_intern_const("nanosecond"); + id_microsecond = rb_intern_const("microsecond"); + id_millisecond = rb_intern_const("millisecond"); + id_second = rb_intern_const("second"); + id_float_microsecond = rb_intern_const("float_microsecond"); + id_float_millisecond = rb_intern_const("float_millisecond"); + id_float_second = rb_intern_const("float_second"); + id_GETTIMEOFDAY_BASED_CLOCK_REALTIME = rb_intern_const("GETTIMEOFDAY_BASED_CLOCK_REALTIME"); + id_TIME_BASED_CLOCK_REALTIME = rb_intern_const("TIME_BASED_CLOCK_REALTIME"); #ifdef HAVE_TIMES - id_TIMES_BASED_CLOCK_MONOTONIC = rb_intern("TIMES_BASED_CLOCK_MONOTONIC"); - id_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID = rb_intern("TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID"); + id_TIMES_BASED_CLOCK_MONOTONIC = rb_intern_const("TIMES_BASED_CLOCK_MONOTONIC"); + id_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID = rb_intern_const("TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID"); #endif #ifdef RUSAGE_SELF - id_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID = rb_intern("GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID"); + id_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID = rb_intern_const("GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID"); #endif - id_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID = rb_intern("CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID"); + id_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID = rb_intern_const("CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID"); #ifdef __APPLE__ - id_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC = rb_intern("MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC"); + id_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC = rb_intern_const("MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC"); #endif - id_hertz = rb_intern("hertz"); + id_hertz = rb_intern_const("hertz"); InitVM(process); } @@ -1839,12 +1839,9 @@ range_count(int argc, VALUE *argv, VALUE range) void Init_Range(void) { -#undef rb_intern -#define rb_intern(str) rb_intern_const(str) - - id_beg = rb_intern("begin"); - id_end = rb_intern("end"); - id_excl = rb_intern("excl"); + id_beg = rb_intern_const("begin"); + id_end = rb_intern_const("end"); + id_excl = rb_intern_const("excl"); rb_cRange = rb_struct_define_without_accessor( "Range", rb_cObject, range_alloc, diff --git a/rational.c b/rational.c index aa90342027..6ac42bff04 100644 --- a/rational.c +++ b/rational.c @@ -2723,13 +2723,10 @@ void Init_Rational(void) { VALUE compat; -#undef rb_intern -#define rb_intern(str) rb_intern_const(str) - - id_abs = rb_intern("abs"); - id_integer_p = rb_intern("integer?"); - id_i_num = rb_intern("@numerator"); - id_i_den = rb_intern("@denominator"); + id_abs = rb_intern_const("abs"); + id_integer_p = rb_intern_const("integer?"); + id_i_num = rb_intern_const("@numerator"); + id_i_den = rb_intern_const("@denominator"); rb_cRational = rb_define_class("Rational", rb_cNumeric); @@ -11418,9 +11418,6 @@ sym_all_symbols(VALUE _) void Init_String(void) { -#undef rb_intern -#define rb_intern(str) rb_intern_const(str) - rb_cString = rb_define_class("String", rb_cObject); assert(rb_vm_fstring_table()); st_foreach(rb_vm_fstring_table(), fstring_set_class_i, rb_cString); @@ -11476,10 +11473,10 @@ Init_String(void) rb_define_method(rb_cString, "dump", rb_str_dump, 0); rb_define_method(rb_cString, "undump", str_undump, 0); - sym_ascii = ID2SYM(rb_intern("ascii")); - sym_turkic = ID2SYM(rb_intern("turkic")); - sym_lithuanian = ID2SYM(rb_intern("lithuanian")); - sym_fold = ID2SYM(rb_intern("fold")); + sym_ascii = ID2SYM(rb_intern_const("ascii")); + sym_turkic = ID2SYM(rb_intern_const("turkic")); + sym_lithuanian = ID2SYM(rb_intern_const("lithuanian")); + sym_fold = ID2SYM(rb_intern_const("fold")); rb_define_method(rb_cString, "upcase", rb_str_upcase, -1); rb_define_method(rb_cString, "downcase", rb_str_downcase, -1); @@ -11572,8 +11569,8 @@ Init_String(void) /* define UnicodeNormalize module here so that we don't have to look it up */ mUnicodeNormalize = rb_define_module("UnicodeNormalize"); - id_normalize = rb_intern("normalize"); - id_normalized_p = rb_intern("normalized?"); + id_normalize = rb_intern_const("normalize"); + id_normalized_p = rb_intern_const("normalized?"); rb_define_method(rb_cString, "unicode_normalize", rb_str_unicode_normalize, -1); rb_define_method(rb_cString, "unicode_normalize!", rb_str_unicode_normalize_bang, -1); diff --git a/template/id.c.tmpl b/template/id.c.tmpl index 477a76bc26..4f30875c04 100644 --- a/template/id.c.tmpl +++ b/template/id.c.tmpl @@ -33,8 +33,6 @@ static const struct { static void Init_id(void) { -#undef rb_intern -#define rb_intern(str) rb_intern_const(str) rb_encoding *enc = rb_usascii_encoding(); % ids[:predefined].each do |token, name| @@ -5459,15 +5459,12 @@ Init_Thread_Mutex() void Init_Thread(void) { -#undef rb_intern -#define rb_intern(str) rb_intern_const(str) - VALUE cThGroup; rb_thread_t *th = GET_THREAD(); - sym_never = ID2SYM(rb_intern("never")); - sym_immediate = ID2SYM(rb_intern("immediate")); - sym_on_blocking = ID2SYM(rb_intern("on_blocking")); + sym_never = ID2SYM(rb_intern_const("never")); + sym_immediate = ID2SYM(rb_intern_const("immediate")); + sym_on_blocking = ID2SYM(rb_intern_const("on_blocking")); rb_define_singleton_method(rb_cThread, "new", thread_s_new, -1); rb_define_singleton_method(rb_cThread, "start", thread_start, -2); @@ -5547,7 +5544,7 @@ Init_Thread(void) rb_define_const(cThGroup, "Default", th->thgroup); } - recursive_key = rb_intern("__recursive_key__"); + recursive_key = rb_intern_const("__recursive_key__"); rb_eThreadError = rb_define_class("ThreadError", rb_eStandardError); /* init thread core */ @@ -5860,29 +5860,26 @@ rb_time_zone_abbreviation(VALUE zone, VALUE time) void Init_Time(void) { -#undef rb_intern -#define rb_intern(str) rb_intern_const(str) - - id_submicro = rb_intern("submicro"); - id_nano_num = rb_intern("nano_num"); - id_nano_den = rb_intern("nano_den"); - id_offset = rb_intern("offset"); - id_zone = rb_intern("zone"); - id_nanosecond = rb_intern("nanosecond"); - id_microsecond = rb_intern("microsecond"); - id_millisecond = rb_intern("millisecond"); - id_nsec = rb_intern("nsec"); - id_usec = rb_intern("usec"); - id_local_to_utc = rb_intern("local_to_utc"); - id_utc_to_local = rb_intern("utc_to_local"); - id_year = rb_intern("year"); - id_mon = rb_intern("mon"); - id_mday = rb_intern("mday"); - id_hour = rb_intern("hour"); - id_min = rb_intern("min"); - id_sec = rb_intern("sec"); - id_isdst = rb_intern("isdst"); - id_find_timezone = rb_intern("find_timezone"); + id_submicro = rb_intern_const("submicro"); + id_nano_num = rb_intern_const("nano_num"); + id_nano_den = rb_intern_const("nano_den"); + id_offset = rb_intern_const("offset"); + id_zone = rb_intern_const("zone"); + id_nanosecond = rb_intern_const("nanosecond"); + id_microsecond = rb_intern_const("microsecond"); + id_millisecond = rb_intern_const("millisecond"); + id_nsec = rb_intern_const("nsec"); + id_usec = rb_intern_const("usec"); + id_local_to_utc = rb_intern_const("local_to_utc"); + id_utc_to_local = rb_intern_const("utc_to_local"); + id_year = rb_intern_const("year"); + id_mon = rb_intern_const("mon"); + id_mday = rb_intern_const("mday"); + id_hour = rb_intern_const("hour"); + id_min = rb_intern_const("min"); + id_sec = rb_intern_const("sec"); + id_isdst = rb_intern_const("isdst"); + id_find_timezone = rb_intern_const("find_timezone"); str_utc = rb_fstring_lit("UTC"); rb_gc_register_mark_object(str_utc); diff --git a/vm_method.c b/vm_method.c index 47ad040914..e229d8b356 100644 --- a/vm_method.c +++ b/vm_method.c @@ -2482,9 +2482,6 @@ Init_Method(void) void Init_eval_method(void) { -#undef rb_intern -#define rb_intern(str) rb_intern_const(str) - rb_define_method(rb_mKernel, "respond_to?", obj_respond_to, -1); rb_define_method(rb_mKernel, "respond_to_missing?", obj_respond_to_missing, 2); |