From 5fad5a107005fc9b1e0bd7032305b942307968c0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Mon, 11 Jan 2021 16:34:05 +0100 Subject: [PATCH] :art: Improve strings --- src/emit/emit.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/emit/emit.c b/src/emit/emit.c index b8ee6971..64e477ba 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -607,15 +607,15 @@ ANN static m_bool emit_prim_char(const Emitter emit, const m_str *str) { } ANN static m_bool emit_prim_str(const Emitter emit, const m_str *str) { - char c[strlen(*str) + 1]; - if(strlen(*str)) { - strcpy(c, *str); - CHECK_BB(escape_str(emit, c, prim_pos(str))); - } else c[0] = '\0'; const Value v = prim_self(str)->value; - const Symbol sym = insert_symbol(c); - if(!v->d.obj) - v->d.obj = new_string2(emit->gwion, NULL, s_name(sym)); + if(!v->d.obj) { + char c[strlen(*str) + 1]; + if(strlen(*str)) { + strcpy(c, *str); + CHECK_BB(escape_str(emit, c, prim_pos(str))); + } else c[0] = '\0'; + v->d.obj = new_string2(emit->gwion, NULL, c); + } regpushi(emit, (m_uint)v->d.obj); emit_object_addref(emit, -SZ_INT, 0); return GW_OK; -- 2.43.0