From f167ae8145eab6e7622fd5f591b9dd22ac117326 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sun, 10 Aug 2025 08:50:46 +0900 Subject: [PATCH] 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 --- src/symbol.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/symbol.c b/src/symbol.c index 99770e9fb..71dde3d72 100644 --- a/src/symbol.c +++ b/src/symbol.c @@ -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;