summaryrefslogtreecommitdiffstats
path: root/parser.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-10-31 06:07:23 -0700
committerKaz Kylheku <kaz@kylheku.com>2018-10-31 06:07:23 -0700
commit5389099d2c9b5f2476499f3813dbcbd2eb44235a (patch)
treec9e35f379fc3e242c18685fd86d13ddd826c5241 /parser.c
parent3bdf25732b26af5037c1bf05b6b09af8fe43f3c7 (diff)
downloadtxr-5389099d2c9b5f2476499f3813dbcbd2eb44235a.tar.gz
txr-5389099d2c9b5f2476499f3813dbcbd2eb44235a.tar.bz2
txr-5389099d2c9b5f2476499f3813dbcbd2eb44235a.zip
repl: allocate the "catch all" exception list once.
* parser.c (catch_all): New static variable. (provide_atom, repl): Use static catch_all. (parse_init): Protect catch_all from GC reclamation.
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/parser.c b/parser.c
index 049da3a7..9e6ae732 100644
--- a/parser.c
+++ b/parser.c
@@ -71,7 +71,7 @@ val listener_pprint_s, listener_greedy_eval_s;
val rec_source_loc_s;
val intr_s;
-static val stream_parser_hash;
+static val stream_parser_hash, catch_all;
static void yy_tok_mark(struct yy_token *tok)
{
@@ -897,7 +897,6 @@ static void provide_completions(const wchar_t *data,
static wchar_t *provide_atom(lino_t *l, const wchar_t *str, int n, void *ctx)
{
- val catch_all = list(t, nao);
val obj = nao;
val form;
val line = string(str);
@@ -1216,7 +1215,6 @@ val repl(val bindings, val in_stream, val out_stream)
val counter_sym = intern(lit("*n"), user_package);
val var_counter_sym = intern(lit("*v"), user_package);
val result_hash_sym = intern(lit("*r"), user_package);
- val catch_all = list(t, nao);
val result_hash = make_hash(nil, nil, nil);
val done = nil;
val counter = one;
@@ -1551,9 +1549,9 @@ void parse_init(void)
listener_greedy_eval_s = intern(lit("*listener-greedy-eval-p*"), user_package);
rec_source_loc_s = intern(lit("*rec-source-loc*"), user_package);
unique_s = gensym(nil);
- prot1(&stream_parser_hash);
- prot1(&unique_s);
+ protect(&stream_parser_hash, &unique_s, &catch_all, convert(val *, 0));
stream_parser_hash = make_hash(t, nil, nil);
+ catch_all = cons(t, nil);
parser_l_init();
lino_init(&linenoise_txr_binding);
reg_var(listener_hist_len_s, num_fast(500));