1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-14 18:42:34 +03:00

Create the beginnings of internals documentation for the regex code.

Create src/backend/regex/README to hold an implementation overview of
the regex package, and fill it in with some preliminary notes about
the code's DFA/NFA processing and colormap management.  Much more to
do there of course.

Also, improve some code comments around the colormap and cvec code.
No functional changes except to add one missing assert.
This commit is contained in:
Tom Lane
2012-02-19 18:57:38 -05:00
parent 2f582f76b1
commit 27af91438b
4 changed files with 343 additions and 16 deletions

View File

@ -77,6 +77,7 @@ static void
addchr(struct cvec * cv, /* character vector */
chr c) /* character to add */
{
assert(cv->nchrs < cv->chrspace);
cv->chrs[cv->nchrs++] = (chr) c;
}
@ -95,17 +96,27 @@ addrange(struct cvec * cv, /* character vector */
}
/*
* getcvec - get a cvec, remembering it as v->cv
* getcvec - get a transient cvec, initialized to empty
*
* The returned cvec is valid only until the next call of getcvec, which
* typically will recycle the space. Callers should *not* free the cvec
* explicitly; it will be cleaned up when the struct vars is destroyed.
*
* This is typically used while interpreting bracket expressions. In that
* usage the cvec is only needed momentarily until we build arcs from it,
* so transientness is a convenient behavior.
*/
static struct cvec *
getcvec(struct vars * v, /* context */
int nchrs, /* to hold this many chrs... */
int nranges) /* ... and this many ranges */
{
/* recycle existing transient cvec if large enough */
if (v->cv != NULL && nchrs <= v->cv->chrspace &&
nranges <= v->cv->rangespace)
return clearcvec(v->cv);
/* nope, make a new one */
if (v->cv != NULL)
freecvec(v->cv);
v->cv = newcvec(nchrs, nranges);