symbol.c: simplify literal check in sym_intern_common

This commit simplifies the logic for checking if a symbol is a literal in the
`sym_intern_common` function by using the `lit = lit || mrb_ro_data_p(name);`
idiom.

Co-authored-by: Gemini <gemini@google.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-08-10 08:50:46 +09:00
parent 8c08103151
commit f167ae8145
+2 -3
View File
@@ -312,9 +312,8 @@ sym_intern_common(mrb_state *mrb, const char *name, size_t len, mrb_bool lit)
mrb->symcapa = symcapa;
}
/* Tag if explicitly marked literal OR detected as read-only (like original) */
mrb_bool is_ro = mrb_ro_data_p(name);
if ((lit || is_ro) && name[len] == 0 && strlen(name) == len) {
lit = lit || mrb_ro_data_p(name);
if (lit && name[len] == 0 && strlen(name) == len) {
if (((uintptr_t)name & 1) != 0) {
/* Fallback: unaligned literal, allocate heap copy */
goto heap_allocation;