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

Commit3cbfe48

Browse files
committed
Remove useless "retry memory" logic within regex engine.
Apparently some primordial version of Spencer's engine needed cdissect()and child functions to be able to continue matching from a previousposition when re-called. That is dead code, though, since trivialinspection shows that cdissect can never be entered without havingpreviously done zapmem which resets the relevant retry counter. I havealso verified experimentally that no case in the Tcl regression testsreaches cdissect with a nonzero retry value. Accordingly, remove thatlogic. This doesn't really save any noticeable number of cycles in itself,but it is one step towards making dissect() and cdissect() equivalent,which will allow removing hundreds of lines of near-duplicated code.Since struct subre's "retry" field is no longer particularly related toany kind of retry, rename it to "id". As of this commit it's only usedfor identifying a subre node in debug printouts, so you might think weshould get rid of the field entirely; but I have a plan for another use.
1 parent1fbacbf commit3cbfe48

File tree

3 files changed

+78
-150
lines changed

3 files changed

+78
-150
lines changed

‎src/backend/regex/regcomp.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,7 +1623,7 @@ subre(struct vars * v,
16231623

16241624
ret->op=op;
16251625
ret->flags=flags;
1626-
ret->retry=0;
1626+
ret->id=0;/* will be assigned later */
16271627
ret->subno=0;
16281628
ret->min=ret->max=1;
16291629
ret->left=NULL;
@@ -1693,7 +1693,7 @@ optst(struct vars * v,
16931693
}
16941694

16951695
/*
1696-
* numst - number tree nodes (assigningretry indexes)
1696+
* numst - number tree nodes (assigning"id" indexes)
16971697
*/
16981698
staticint/* next number */
16991699
numst(structsubre*t,
@@ -1704,7 +1704,7 @@ numst(struct subre * t,
17041704
assert(t!=NULL);
17051705

17061706
i=start;
1707-
t->retry= (short)i++;
1707+
t->id= (short)i++;
17081708
if (t->left!=NULL)
17091709
i=numst(t->left,i);
17101710
if (t->right!=NULL)
@@ -1999,11 +1999,11 @@ stid(struct subre * t,
19991999
char*buf,
20002000
size_tbufsize)
20012001
{
2002-
/* big enough for hex int or decimal t->retry? */
2003-
if (bufsize<sizeof(void*)*2+3||bufsize<sizeof(t->retry)*3+1)
2002+
/* big enough for hex int or decimal t->id? */
2003+
if (bufsize<sizeof(void*)*2+3||bufsize<sizeof(t->id)*3+1)
20042004
return"unable";
2005-
if (t->retry!=0)
2006-
sprintf(buf,"%d",t->retry);
2005+
if (t->id!=0)
2006+
sprintf(buf,"%d",t->id);
20072007
else
20082008
sprintf(buf,"%p",t);
20092009
returnbuf;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp