From 6e60bebf3db66ff7aa63ad84556f2665d4bf605a Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Mon, 8 Apr 2024 10:32:06 -0700 Subject: [PATCH] Faster rewrite --- src/modal.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modal.c b/src/modal.c index 7cf6066..adc3bf6 100644 --- a/src/modal.c +++ b/src/modal.c @@ -11,7 +11,7 @@ static char bank_a[0x4000], *prog_ = bank_a; static char bank_b[0x4000], *outp_ = bank_b; static char *regs[0x100]; -#define spacer(c) (c < 0x21 || c == '(' || c == ')') +#define spacer(c) (c < 0x21 || c == '(' || c == ')' || !c) static char * walk(char *s) @@ -149,13 +149,13 @@ add_rule(char *p) static int rewrite(void) { - char c, c_ = 0, last = 0, *p = direction ? bank_b : bank_a, *o = p; + char c, last = 0, *p = direction ? bank_b : bank_a; while((c = *p) && c <= ' ') p++; while((c = *p)) { int i; - if(p[0] == '<' && p[1] == '>') return add_rule(p); - if(p != o) c_ = *(p - 1); - if(p == o || spacer(c_)) { + if(p[0] == '<' && p[1] == '>') + return add_rule(p); + if(spacer(last)) { for(i = 0; i < rules_len; i++) { Rule *r = &rules[i]; char *res = match_rule(p, r);