diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2018-11-02 06:14:03 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2018-11-02 06:14:03 -0700 |
commit | 1cf6c607eb35525d2329651e1d75f21b3a8e82b2 (patch) | |
tree | 149bdc84a3b367287e1a25781c990c97401f955a /parser.c | |
parent | 62fc840c57cbaab249929126eb592d30d9554f9d (diff) | |
download | txr-1cf6c607eb35525d2329651e1d75f21b3a8e82b2.tar.gz txr-1cf6c607eb35525d2329651e1d75f21b3a8e82b2.tar.bz2 txr-1cf6c607eb35525d2329651e1d75f21b3a8e82b2.zip |
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.
Diffstat (limited to 'parser.c')
-rw-r--r-- | parser.c | 3 |
1 files changed, 1 insertions, 2 deletions
@@ -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); |