diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-06-28 22:54:13 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-06-30 23:59:05 +0900 |
commit | ac0163949a6ee678dfccec9f6e56422b91e5f0a9 (patch) | |
tree | e7181fc3f4349654459fa8801d080d6b5a362504 /symbol.c | |
parent | 469e644c93a0410b2b3a3a7523aed017e4f62715 (diff) |
Compile code without Symbol GC always
Diffstat (limited to 'symbol.c')
-rw-r--r-- | symbol.c | 28 |
1 files changed, 13 insertions, 15 deletions
@@ -23,7 +23,11 @@ #include "vm_sync.h" #include "builtin.h" -#ifndef USE_SYMBOL_GC +#if defined(USE_SYMBOL_GC) && !(USE_SYMBOL_GC+0) +# undef USE_SYMBOL_GC +# define USE_SYMBOL_GC 0 +#else +# undef USE_SYMBOL_GC # define USE_SYMBOL_GC 1 #endif #ifndef SYMBOL_DEBUG @@ -843,12 +847,7 @@ VALUE rb_str_intern(VALUE str) { VALUE sym; -#if USE_SYMBOL_GC - rb_encoding *enc, *ascii; - int type; -#else - ID id; -#endif + GLOBAL_SYMBOLS_ENTER(symbols); { sym = lookup_str_sym_with_lock(symbols, str); @@ -856,10 +855,9 @@ rb_str_intern(VALUE str) if (sym) { // ok } - else { -#if USE_SYMBOL_GC - enc = rb_enc_get(str); - ascii = rb_usascii_encoding(); + else if (USE_SYMBOL_GC) { + rb_encoding *enc = rb_enc_get(str); + rb_encoding *ascii = rb_usascii_encoding(); if (enc != ascii && sym_check_asciionly(str)) { str = rb_str_dup(str); rb_enc_associate(str, ascii); @@ -871,13 +869,13 @@ rb_str_intern(VALUE str) OBJ_FREEZE(str); } str = rb_fstring(str); - type = rb_str_symname_type(str, IDSET_ATTRSET_FOR_INTERN); + int type = rb_str_symname_type(str, IDSET_ATTRSET_FOR_INTERN); if (type < 0) type = ID_JUNK; sym = dsymbol_alloc(symbols, rb_cSymbol, str, enc, type); -#else - id = intern_str(str, 0); + } + else { + ID id = intern_str(str, 0); sym = ID2SYM(id); -#endif } } GLOBAL_SYMBOLS_LEAVE(); |