Reduce register clearing tasks

This commit is contained in:
Devine Lu Linvega 2024-04-16 13:51:34 -07:00
parent acb655ad10
commit 8df2a496cc
1 changed files with 10 additions and 4 deletions

View File

@ -5,7 +5,7 @@ typedef struct {
char *a, *b;
} Rule;
static int flip, cycles = 0x10000;
static int flip, rmin = 0xff, rmax = 0x00, cycles = 0x10000;
static Rule rules[0x1000], lambda, *rules_ = rules;
static char dict[0x8000], *dict_ = dict;
static char bank_a[0x4000], *src_ = bank_a;
@ -37,8 +37,11 @@ set_reg(int r, char *b)
char *a = regs[r], *aa = walk(a), *bb = walk(b);
while(a < aa && b < bb)
if(*a++ != *b++) return 0;
} else
} else {
regs[r] = b;
if(r < rmin) rmin = r;
if(r > rmax) rmax = r;
}
return 1;
}
@ -87,8 +90,11 @@ match_rule(Rule *r, char *p)
{
int i;
char c, last = 0, *a = r->a, *b = p;
for(i = 0x21; i < 0x7f; i++)
if(rmax) {
for(i = 0; i <= rmax; i++)
regs[i] = 0;
rmin = 0xff, rmax = 0x00;
}
while((c = *a)) {
if(spacer(last) && c == '?') {
if(!set_reg(*(++a), b)) return NULL;