pgsql: Simplify and document regex library's compact-NFA representation

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Simplify and document regex library's compact-NFA representation
Date: 2012-07-07 21:40:02
Message-ID: E1SncjS-0000Dj-Af@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Simplify and document regex library's compact-NFA representation.

The previous coding abused the first element of a cNFA state's arcs list
to hold a per-state flag bit, which was confusing, undocumented, and not
even particularly efficient. Get rid of that in favor of a separate
"stflags" vector. Since there's only one bit in use, I chose to allocate a
char per state; we could possibly replace this with a bitmap at some point,
but that would make accesses a little slower. It's already about 8X
smaller than before, so let's not get overly tense.

Also document the representation better than it was before, which is to say
not at all.

This patch is a byproduct of investigations towards extracting a "fixed
prefix" string from the compact-NFA representation of regex patterns.
Might need to back-patch it if we decide to back-patch that fix, but for
now it's just code cleanup so I'll just put it in HEAD.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/c6aae3042be5249e672b731ebeb21875b5343010

Modified Files
--------------
src/backend/regex/regc_nfa.c | 34 +++++++++++++++++-----------------
src/backend/regex/regcomp.c | 2 +-
src/backend/regex/rege_dfa.c | 11 +++++------
src/include/regex/regguts.h | 29 +++++++++++++++++++++--------
4 files changed, 44 insertions(+), 32 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2012-07-09 03:53:07 pgsql: Fix planner to pass correct collation to operator selectivity es
Previous Message User Fxjr 2012-07-07 02:44:34 npgsql - Npgsql2: release notes for .94 release.