mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
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:
+2
-3
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user