Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit90401eb

Browse files
committed
factor out sparse
1 parent703cf8a commit90401eb

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

‎pike.c‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -400,11 +400,13 @@ int re_comp(rcode *prog, const char *re, int nsubs)
400400
icnt++;
401401
break;
402402
caseSPLIT:
403-
prog->insts[i++]=scnt++;
403+
prog->insts[i++]=scnt;
404+
scnt+=2;
404405
icnt++;
405406
break;
406407
caseRSPLIT:
407-
prog->insts[i]=-scnt++;
408+
prog->insts[i]=-scnt;
409+
scnt+=2;
408410
caseJMP:
409411
caseSAVE:
410412
caseCHAR:
@@ -415,7 +417,7 @@ int re_comp(rcode *prog, const char *re, int nsubs)
415417
prog->insts[prog->unilen++]=SAVE;
416418
prog->insts[prog->unilen++]=prog->sub+1;
417419
prog->insts[prog->unilen++]=MATCH;
418-
prog->splits=scnt;
420+
prog->splits=(scnt-SPLIT) /2+SPLIT;
419421
prog->len=icnt+2;
420422
returnRE_SUCCESS;
421423
}
@@ -437,11 +439,12 @@ if (--csub->ref == 0) { \
437439

438440
#defineonclist(nn)
439441
#defineonnlist(nn) \
440-
if (sparse[spc] < sparsesz) \
441-
if (sdense[sparse[spc]] == spc) \
442+
if (sdense[spc+1] < sparsesz) \
443+
if (sdense[sdense[spc+1]] ==(unsigned int)spc) \
442444
deccheck(nn) \
445+
sdense[spc+1] = sparsesz; \
443446
sdense[sparsesz] = spc; \
444-
sparse[spc] = sparsesz++; \
447+
sparsesz += 2; \
445448

446449
#definefastrec(nn,list,listidx) \
447450
nsub->ref++; \
@@ -545,11 +548,11 @@ int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp)
545548
{
546549
intrsubsize=sizeof(rsub)+(sizeof(char*)*nsubp);
547550
intsi,i,j,c,suboff=rsubsize,*npc,osubp=nsubp*sizeof(char*);
548-
intclistidx=0,nlistidx,sparsesz,spc,mcont=MATCH;
551+
intclistidx=0,nlistidx,spc,mcont=MATCH;
549552
constchar*sp=s,*_sp=s;
550553
int*insts=prog->insts;
551554
int*pcs[prog->splits];
552-
unsignedintsdense[prog->splits],sparse[prog->splits];
555+
unsignedintsdense[prog->splits*2],sparsesz;
553556
rsub*subs[prog->splits];
554557
charnsubs[rsubsize* (prog->len-prog->splits+14)];
555558
rsub*nsub,*s1,*matched=NULL,*freesub=NULL;
@@ -560,7 +563,7 @@ int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp)
560563
for (;;sp=_sp) {
561564
uc_len(i,sp)uc_code(c,sp)
562565
_sp=sp+i;
563-
nlistidx=0;sparsesz=0;
566+
nlistidx=0;sparsesz=SPLIT;
564567
for (i=0;i<clistidx;i++) {
565568
npc=clist[i].pc;
566569
nsub=clist[i].sub;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp