Skip to content

Commit 5a77e90

Browse files
committed
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.
1 parent 8c2e5bb commit 5a77e90

File tree

7 files changed

+42
-42
lines changed

7 files changed

+42
-42
lines changed

error.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2817,7 +2817,7 @@ Init_Exception(void)
28172817

28182818
warning_categories = rb_hash_new();
28192819
rb_gc_register_mark_object(warning_categories);
2820-
rb_hash_aset(warning_categories, ID2SYM(rb_intern("deprecated")), Qtrue);
2820+
rb_hash_aset(warning_categories, ID2SYM(rb_intern_const("deprecated")), Qtrue);
28212821
rb_obj_freeze(warning_categories);
28222822
}
28232823

ext/-test-/memory_view/memory_view.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -350,35 +350,35 @@ Init_memory_view(void)
350350
rb_define_method(cMDView, "[]", mdview_aref, 1);
351351
rb_memory_view_register(cMDView, &mdview_memory_view_entry);
352352

353-
id_str = rb_intern("__str__");
354-
sym_format = ID2SYM(rb_intern("format"));
355-
sym_native_size_p = ID2SYM(rb_intern("native_size_p"));
356-
sym_offset = ID2SYM(rb_intern("offset"));
357-
sym_size = ID2SYM(rb_intern("size"));
358-
sym_repeat = ID2SYM(rb_intern("repeat"));
359-
sym_obj = ID2SYM(rb_intern("obj"));
360-
sym_len = ID2SYM(rb_intern("len"));
361-
sym_readonly = ID2SYM(rb_intern("readonly"));
362-
sym_format = ID2SYM(rb_intern("format"));
363-
sym_item_size = ID2SYM(rb_intern("item_size"));
364-
sym_ndim = ID2SYM(rb_intern("ndim"));
365-
sym_shape = ID2SYM(rb_intern("shape"));
366-
sym_strides = ID2SYM(rb_intern("strides"));
367-
sym_sub_offsets = ID2SYM(rb_intern("sub_offsets"));
368-
sym_endianness = ID2SYM(rb_intern("endianness"));
369-
sym_little_endian = ID2SYM(rb_intern("little_endian"));
370-
sym_big_endian = ID2SYM(rb_intern("big_endian"));
353+
id_str = rb_intern_const("__str__");
354+
sym_format = ID2SYM(rb_intern_const("format"));
355+
sym_native_size_p = ID2SYM(rb_intern_const("native_size_p"));
356+
sym_offset = ID2SYM(rb_intern_const("offset"));
357+
sym_size = ID2SYM(rb_intern_const("size"));
358+
sym_repeat = ID2SYM(rb_intern_const("repeat"));
359+
sym_obj = ID2SYM(rb_intern_const("obj"));
360+
sym_len = ID2SYM(rb_intern_const("len"));
361+
sym_readonly = ID2SYM(rb_intern_const("readonly"));
362+
sym_format = ID2SYM(rb_intern_const("format"));
363+
sym_item_size = ID2SYM(rb_intern_const("item_size"));
364+
sym_ndim = ID2SYM(rb_intern_const("ndim"));
365+
sym_shape = ID2SYM(rb_intern_const("shape"));
366+
sym_strides = ID2SYM(rb_intern_const("strides"));
367+
sym_sub_offsets = ID2SYM(rb_intern_const("sub_offsets"));
368+
sym_endianness = ID2SYM(rb_intern_const("endianness"));
369+
sym_little_endian = ID2SYM(rb_intern_const("little_endian"));
370+
sym_big_endian = ID2SYM(rb_intern_const("big_endian"));
371371

372372
#ifdef WORDS_BIGENDIAN
373-
rb_const_set(mMemoryViewTestUtils, rb_intern("NATIVE_ENDIAN"), sym_big_endian);
373+
rb_const_set(mMemoryViewTestUtils, rb_intern_const("NATIVE_ENDIAN"), sym_big_endian);
374374
#else
375-
rb_const_set(mMemoryViewTestUtils, rb_intern("NATIVE_ENDIAN"), sym_little_endian);
375+
rb_const_set(mMemoryViewTestUtils, rb_intern_const("NATIVE_ENDIAN"), sym_little_endian);
376376
#endif
377377

378378
#define DEF_ALIGNMENT_CONST(type, TYPE) do { \
379379
int alignment; \
380380
STRUCT_ALIGNOF(type, alignment); \
381-
rb_const_set(mMemoryViewTestUtils, rb_intern(#TYPE "_ALIGNMENT"), INT2FIX(alignment)); \
381+
rb_const_set(mMemoryViewTestUtils, rb_intern_const(#TYPE "_ALIGNMENT"), INT2FIX(alignment)); \
382382
} while(0)
383383

384384
DEF_ALIGNMENT_CONST(short, SHORT);

ext/-test-/string/coderange.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ str_coderange_scan(VALUE str)
3838
void
3939
Init_string_coderange(VALUE klass)
4040
{
41-
sym_7bit = ID2SYM(rb_intern("7bit"));
42-
sym_valid = ID2SYM(rb_intern("valid"));
43-
sym_unknown = ID2SYM(rb_intern("unknown"));
44-
sym_broken = ID2SYM(rb_intern("broken"));
41+
sym_7bit = ID2SYM(rb_intern_const("7bit"));
42+
sym_valid = ID2SYM(rb_intern_const("valid"));
43+
sym_unknown = ID2SYM(rb_intern_const("unknown"));
44+
sym_broken = ID2SYM(rb_intern_const("broken"));
4545
rb_define_method(klass, "coderange", str_coderange, 0);
4646
rb_define_method(klass, "coderange_scan", str_coderange_scan, 0);
4747
}

ext/openssl/ossl_ts.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,24 +1247,24 @@ Init_ossl_ts(void)
12471247
* timestamp server rejects the message imprint algorithm used in the
12481248
* +Request+
12491249
*/
1250-
sBAD_ALG = rb_intern("BAD_ALG");
1250+
sBAD_ALG = rb_intern_const("BAD_ALG");
12511251

12521252
/*
12531253
* Possible return value for +Response#failure_info+. Indicates that the
12541254
* timestamp server was not able to process the +Request+ properly.
12551255
*/
1256-
sBAD_REQUEST = rb_intern("BAD_REQUEST");
1256+
sBAD_REQUEST = rb_intern_const("BAD_REQUEST");
12571257
/*
12581258
* Possible return value for +Response#failure_info+. Indicates that the
12591259
* timestamp server was not able to parse certain data in the +Request+.
12601260
*/
1261-
sBAD_DATA_FORMAT = rb_intern("BAD_DATA_FORMAT");
1261+
sBAD_DATA_FORMAT = rb_intern_const("BAD_DATA_FORMAT");
12621262

1263-
sTIME_NOT_AVAILABLE = rb_intern("TIME_NOT_AVAILABLE");
1264-
sUNACCEPTED_POLICY = rb_intern("UNACCEPTED_POLICY");
1265-
sUNACCEPTED_EXTENSION = rb_intern("UNACCEPTED_EXTENSION");
1266-
sADD_INFO_NOT_AVAILABLE = rb_intern("ADD_INFO_NOT_AVAILABLE");
1267-
sSYSTEM_FAILURE = rb_intern("SYSTEM_FAILURE");
1263+
sTIME_NOT_AVAILABLE = rb_intern_const("TIME_NOT_AVAILABLE");
1264+
sUNACCEPTED_POLICY = rb_intern_const("UNACCEPTED_POLICY");
1265+
sUNACCEPTED_EXTENSION = rb_intern_const("UNACCEPTED_EXTENSION");
1266+
sADD_INFO_NOT_AVAILABLE = rb_intern_const("ADD_INFO_NOT_AVAILABLE");
1267+
sSYSTEM_FAILURE = rb_intern_const("SYSTEM_FAILURE");
12681268

12691269
/* Document-class: OpenSSL::Timestamp
12701270
* Provides classes and methods to request, create and validate
@@ -1503,11 +1503,11 @@ Init_ossl_ts(void)
15031503
*
15041504
*/
15051505
cTimestampFactory = rb_define_class_under(mTimestamp, "Factory", rb_cObject);
1506-
rb_attr(cTimestampFactory, rb_intern("allowed_digests"), 1, 1, 0);
1507-
rb_attr(cTimestampFactory, rb_intern("default_policy_id"), 1, 1, 0);
1508-
rb_attr(cTimestampFactory, rb_intern("serial_number"), 1, 1, 0);
1509-
rb_attr(cTimestampFactory, rb_intern("gen_time"), 1, 1, 0);
1510-
rb_attr(cTimestampFactory, rb_intern("additional_certs"), 1, 1, 0);
1506+
rb_attr(cTimestampFactory, rb_intern_const("allowed_digests"), 1, 1, 0);
1507+
rb_attr(cTimestampFactory, rb_intern_const("default_policy_id"), 1, 1, 0);
1508+
rb_attr(cTimestampFactory, rb_intern_const("serial_number"), 1, 1, 0);
1509+
rb_attr(cTimestampFactory, rb_intern_const("gen_time"), 1, 1, 0);
1510+
rb_attr(cTimestampFactory, rb_intern_const("additional_certs"), 1, 1, 0);
15111511
rb_define_method(cTimestampFactory, "create_timestamp", ossl_tsfac_create_ts, 3);
15121512
}
15131513

ext/racc/cparse/cparse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ void
820820
Init_cparse(void)
821821
{
822822
VALUE Racc, Parser;
823-
ID id_racc = rb_intern("Racc");
823+
ID id_racc = rb_intern_const("Racc");
824824

825825
if (rb_const_defined(rb_cObject, id_racc)) {
826826
Racc = rb_const_get(rb_cObject, id_racc);

memory_view.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,5 +502,5 @@ rb_memory_view_release(rb_memory_view_t* view)
502502
void
503503
Init_MemoryView(void)
504504
{
505-
id_memory_view = rb_intern("__memory_view__");
505+
id_memory_view = rb_intern_const("__memory_view__");
506506
}

time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5686,7 +5686,7 @@ Init_tm(VALUE outer, const char *name)
56865686
#endif
56875687
rb_define_method(tm, "initialize", tm_initialize, -1);
56885688
rb_define_method(tm, "utc", tm_to_time, 0);
5689-
rb_alias(tm, rb_intern("to_time"), rb_intern("utc"));
5689+
rb_alias(tm, rb_intern_const("to_time"), rb_intern_const("utc"));
56905690
rb_define_singleton_method(tm, "from_time", tm_from_time, 1);
56915691
/* :startdoc:*/
56925692

0 commit comments

Comments
 (0)