From 4ac3a6eb635a27c189dd75f75a75f90d84cd5229 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 2 Nov 2018 06:14:03 -0700 Subject: listener: avoid unnecessary string duplication. * parser.c (repl): There is no need to use chk_strdup on the string inside histfile. We can just use the original string, since it won't be garbage collected. The existing gc_hint(histfile) at the end of the function ensures this. The reason the chk_strdup was done is that originally this was a utf8_dup_to that I just blindly replaced when the listener Unicode conversion took place. --- parser.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/parser.c b/parser.c index 845f3f25..778fad12 100644 --- a/parser.c +++ b/parser.c @@ -1220,7 +1220,7 @@ val repl(val bindings, val in_stream, val out_stream) val counter = one; val home = get_home_path(); val histfile = if2(home, format(nil, lit("~a/.txr_history"), home, nao)); - wchar_t *histfile_w = if3(home, chk_strdup(c_str(histfile)), NULL); + const wchar_t *histfile_w = if3(home, c_str(histfile), NULL); val rcfile = if2(home, format(nil, lit("~a/.txr_profile"), home, nao)); val old_sig_handler = set_sig_handler(num(SIGINT), func_n2(repl_intr)); val hist_len_var = lookup_global_var(listener_hist_len_s); @@ -1379,7 +1379,6 @@ val repl(val bindings, val in_stream, val out_stream) if (histfile_w) lino_hist_save(ls, histfile_w); - free(histfile_w); free(line_w); lino_free(ls); gc_hint(histfile); -- cgit v1.2.3