[前][次][番号順一覧][スレッド一覧]

ruby-changes:63401

From: Nobuyoshi <ko1@a...>
Date: Wed, 21 Oct 2020 12:49:13 +0900 (JST)
Subject: [ruby-changes:63401] 5a77e90fe8 (master): Use rb_intern_const instead of rb_intern in Init functions

https://git.ruby-lang.org/ruby.git/commit/?id=5a77e90fe8

From 5a77e90fe843a2bfbde3df1867f142efb0ffe9fe Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Wed, 21 Oct 2020 12:46:40 +0900
Subject: Use rb_intern_const instead of rb_intern in Init functions

```
find . -name \*.o -exec nm {} + |&
sed '/Init_.*\.rbimpl_id/!d;s/^.* b //;s/\.[1-9][0-9]*$//;s/\.rbimpl_id$//' |
uniq
```
should be empty.

diff --git a/error.c b/error.c
index 4d534f7..d58075f 100644
--- a/error.c
+++ b/error.c
@@ -2817,7 +2817,7 @@ Init_Exception(void) https://github.com/ruby/ruby/blob/trunk/error.c#L2817
 
     warning_categories = rb_hash_new();
     rb_gc_register_mark_object(warning_categories);
-    rb_hash_aset(warning_categories, ID2SYM(rb_intern("deprecated")), Qtrue);
+    rb_hash_aset(warning_categories, ID2SYM(rb_intern_const("deprecated")), Qtrue);
     rb_obj_freeze(warning_categories);
 }
 
diff --git a/ext/-test-/memory_view/memory_view.c b/ext/-test-/memory_view/memory_view.c
index a59e7b8..0ae9f45 100644
--- a/ext/-test-/memory_view/memory_view.c
+++ b/ext/-test-/memory_view/memory_view.c
@@ -350,35 +350,35 @@ Init_memory_view(void) https://github.com/ruby/ruby/blob/trunk/ext/-test-/memory_view/memory_view.c#L350
     rb_define_method(cMDView, "[]", mdview_aref, 1);
     rb_memory_view_register(cMDView, &mdview_memory_view_entry);
 
-    id_str = rb_intern("__str__");
-    sym_format = ID2SYM(rb_intern("format"));
-    sym_native_size_p = ID2SYM(rb_intern("native_size_p"));
-    sym_offset = ID2SYM(rb_intern("offset"));
-    sym_size = ID2SYM(rb_intern("size"));
-    sym_repeat = ID2SYM(rb_intern("repeat"));
-    sym_obj = ID2SYM(rb_intern("obj"));
-    sym_len = ID2SYM(rb_intern("len"));
-    sym_readonly = ID2SYM(rb_intern("readonly"));
-    sym_format = ID2SYM(rb_intern("format"));
-    sym_item_size = ID2SYM(rb_intern("item_size"));
-    sym_ndim = ID2SYM(rb_intern("ndim"));
-    sym_shape = ID2SYM(rb_intern("shape"));
-    sym_strides = ID2SYM(rb_intern("strides"));
-    sym_sub_offsets = ID2SYM(rb_intern("sub_offsets"));
-    sym_endianness = ID2SYM(rb_intern("endianness"));
-    sym_little_endian = ID2SYM(rb_intern("little_endian"));
-    sym_big_endian = ID2SYM(rb_intern("big_endian"));
+    id_str = rb_intern_const("__str__");
+    sym_format = ID2SYM(rb_intern_const("format"));
+    sym_native_size_p = ID2SYM(rb_intern_const("native_size_p"));
+    sym_offset = ID2SYM(rb_intern_const("offset"));
+    sym_size = ID2SYM(rb_intern_const("size"));
+    sym_repeat = ID2SYM(rb_intern_const("repeat"));
+    sym_obj = ID2SYM(rb_intern_const("obj"));
+    sym_len = ID2SYM(rb_intern_const("len"));
+    sym_readonly = ID2SYM(rb_intern_const("readonly"));
+    sym_format = ID2SYM(rb_intern_const("format"));
+    sym_item_size = ID2SYM(rb_intern_const("item_size"));
+    sym_ndim = ID2SYM(rb_intern_const("ndim"));
+    sym_shape = ID2SYM(rb_intern_const("shape"));
+    sym_strides = ID2SYM(rb_intern_const("strides"));
+    sym_sub_offsets = ID2SYM(rb_intern_const("sub_offsets"));
+    sym_endianness = ID2SYM(rb_intern_const("endianness"));
+    sym_little_endian = ID2SYM(rb_intern_const("little_endian"));
+    sym_big_endian = ID2SYM(rb_intern_const("big_endian"));
 
 #ifdef WORDS_BIGENDIAN
-    rb_const_set(mMemoryViewTestUtils, rb_intern("NATIVE_ENDIAN"), sym_big_endian);
+    rb_const_set(mMemoryViewTestUtils, rb_intern_const("NATIVE_ENDIAN"), sym_big_endian);
 #else
-    rb_const_set(mMemoryViewTestUtils, rb_intern("NATIVE_ENDIAN"), sym_little_endian);
+    rb_const_set(mMemoryViewTestUtils, rb_intern_const("NATIVE_ENDIAN"), sym_little_endian);
 #endif
 
 #define DEF_ALIGNMENT_CONST(type, TYPE) do { \
     int alignment; \
     STRUCT_ALIGNOF(type, alignment); \
-    rb_const_set(mMemoryViewTestUtils, rb_intern(#TYPE "_ALIGNMENT"), INT2FIX(alignment)); \
+    rb_const_set(mMemoryViewTestUtils, rb_intern_const(#TYPE "_ALIGNMENT"), INT2FIX(alignment)); \
 } while(0)
 
     DEF_ALIGNMENT_CONST(short, SHORT);
diff --git a/ext/-test-/string/coderange.c b/ext/-test-/string/coderange.c
index 1342ce2..bc998ca 100644
--- a/ext/-test-/string/coderange.c
+++ b/ext/-test-/string/coderange.c
@@ -38,10 +38,10 @@ str_coderange_scan(VALUE str) https://github.com/ruby/ruby/blob/trunk/ext/-test-/string/coderange.c#L38
 void
 Init_string_coderange(VALUE klass)
 {
-    sym_7bit = ID2SYM(rb_intern("7bit"));
-    sym_valid = ID2SYM(rb_intern("valid"));
-    sym_unknown = ID2SYM(rb_intern("unknown"));
-    sym_broken = ID2SYM(rb_intern("broken"));
+    sym_7bit = ID2SYM(rb_intern_const("7bit"));
+    sym_valid = ID2SYM(rb_intern_const("valid"));
+    sym_unknown = ID2SYM(rb_intern_const("unknown"));
+    sym_broken = ID2SYM(rb_intern_const("broken"));
     rb_define_method(klass, "coderange", str_coderange, 0);
     rb_define_method(klass, "coderange_scan", str_coderange_scan, 0);
 }
diff --git a/ext/openssl/ossl_ts.c b/ext/openssl/ossl_ts.c
index 160ec0d..d3209c3 100644
--- a/ext/openssl/ossl_ts.c
+++ b/ext/openssl/ossl_ts.c
@@ -1247,24 +1247,24 @@ Init_ossl_ts(void) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ts.c#L1247
      * timestamp server rejects the message imprint algorithm used in the
      * +Request+
      */
-    sBAD_ALG = rb_intern("BAD_ALG");
+    sBAD_ALG = rb_intern_const("BAD_ALG");
 
     /*
      * Possible return value for +Response#failure_info+. Indicates that the
      * timestamp server was not able to process the +Request+ properly.
      */
-    sBAD_REQUEST = rb_intern("BAD_REQUEST");
+    sBAD_REQUEST = rb_intern_const("BAD_REQUEST");
     /*
      * Possible return value for +Response#failure_info+. Indicates that the
      * timestamp server was not able to parse certain data in the +Request+.
      */
-    sBAD_DATA_FORMAT = rb_intern("BAD_DATA_FORMAT");
+    sBAD_DATA_FORMAT = rb_intern_const("BAD_DATA_FORMAT");
 
-    sTIME_NOT_AVAILABLE = rb_intern("TIME_NOT_AVAILABLE");
-    sUNACCEPTED_POLICY = rb_intern("UNACCEPTED_POLICY");
-    sUNACCEPTED_EXTENSION = rb_intern("UNACCEPTED_EXTENSION");
-    sADD_INFO_NOT_AVAILABLE = rb_intern("ADD_INFO_NOT_AVAILABLE");
-    sSYSTEM_FAILURE = rb_intern("SYSTEM_FAILURE");
+    sTIME_NOT_AVAILABLE = rb_intern_const("TIME_NOT_AVAILABLE");
+    sUNACCEPTED_POLICY = rb_intern_const("UNACCEPTED_POLICY");
+    sUNACCEPTED_EXTENSION = rb_intern_const("UNACCEPTED_EXTENSION");
+    sADD_INFO_NOT_AVAILABLE = rb_intern_const("ADD_INFO_NOT_AVAILABLE");
+    sSYSTEM_FAILURE = rb_intern_const("SYSTEM_FAILURE");
 
     /* Document-class: OpenSSL::Timestamp
      * Provides classes and methods to request, create and validate
@@ -1503,11 +1503,11 @@ Init_ossl_ts(void) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ts.c#L1503
      *
      */
     cTimestampFactory = rb_define_class_under(mTimestamp, "Factory", rb_cObject);
-    rb_attr(cTimestampFactory, rb_intern("allowed_digests"), 1, 1, 0);
-    rb_attr(cTimestampFactory, rb_intern("default_policy_id"), 1, 1, 0);
-    rb_attr(cTimestampFactory, rb_intern("serial_number"), 1, 1, 0);
-    rb_attr(cTimestampFactory, rb_intern("gen_time"), 1, 1, 0);
-    rb_attr(cTimestampFactory, rb_intern("additional_certs"), 1, 1, 0);
+    rb_attr(cTimestampFactory, rb_intern_const("allowed_digests"), 1, 1, 0);
+    rb_attr(cTimestampFactory, rb_intern_const("default_policy_id"), 1, 1, 0);
+    rb_attr(cTimestampFactory, rb_intern_const("serial_number"), 1, 1, 0);
+    rb_attr(cTimestampFactory, rb_intern_const("gen_time"), 1, 1, 0);
+    rb_attr(cTimestampFactory, rb_intern_const("additional_certs"), 1, 1, 0);
     rb_define_method(cTimestampFactory, "create_timestamp", ossl_tsfac_create_ts, 3);
 }
 
diff --git a/ext/racc/cparse/cparse.c b/ext/racc/cparse/cparse.c
index 487784a..8fa1069 100644
--- a/ext/racc/cparse/cparse.c
+++ b/ext/racc/cparse/cparse.c
@@ -820,7 +820,7 @@ void https://github.com/ruby/ruby/blob/trunk/ext/racc/cparse/cparse.c#L820
 Init_cparse(void)
 {
     VALUE Racc, Parser;
-    ID id_racc = rb_intern("Racc");
+    ID id_racc = rb_intern_const("Racc");
 
     if (rb_const_defined(rb_cObject, id_racc)) {
         Racc = rb_const_get(rb_cObject, id_racc);
diff --git a/memory_view.c b/memory_view.c
index 4f3d8e3..b2d81cb 100644
--- a/memory_view.c
+++ b/memory_view.c
@@ -502,5 +502,5 @@ rb_memory_view_release(rb_memory_view_t* view) https://github.com/ruby/ruby/blob/trunk/memory_view.c#L502
 void
 Init_MemoryView(void)
 {
-    id_memory_view = rb_intern("__memory_view__");
+    id_memory_view = rb_intern_const("__memory_view__");
 }
diff --git a/time.c b/time.c
index 0b3692f..ff236ce 100644
--- a/time.c
+++ b/time.c
@@ -5686,7 +5686,7 @@ Init_tm(VALUE outer, const char *name) https://github.com/ruby/ruby/blob/trunk/time.c#L5686
 #endif
     rb_define_method(tm, "initialize", tm_initialize, -1);
     rb_define_method(tm, "utc", tm_to_time, 0);
-    rb_alias(tm, rb_intern("to_time"), rb_intern("utc"));
+    rb_alias(tm, rb_intern_const("to_time"), rb_intern_const("utc"));
     rb_define_singleton_method(tm, "from_time", tm_from_time, 1);
     /* :startdoc:*/
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]