diff options
author | Teodor Sigaev | 2007-09-11 08:46:29 +0000 |
---|---|---|
committer | Teodor Sigaev | 2007-09-11 08:46:29 +0000 |
commit | 57cafe79823dcd3653cf5e19cbdf58300cb1576c (patch) | |
tree | 8616fa0d0c77fd151cf874184fa5f21f56717aef /src/include | |
parent | ef4d38c86c1b1f834bd70115fd19f03431573c2d (diff) |
Refactor from Heikki Linnakangas <[email protected]>:
* Defined new struct WordEntryPosVector that holds a uint16 length and a
variable size array of WordEntries. This replaces the previous
convention of a variable size uint16 array, with the first element
implying the length. WordEntryPosVector has the same layout in memory,
but is more readable in source code. The POSDATAPTR and POSDATALEN
macros are still used, though it would now be more readable to access
the fields in WordEntryPosVector directly.
* Removed needfree field from DocRepresentation. It was always set to false.
* Miscellaneous other commenting and refactoring
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/tsearch/ts_type.h | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/include/tsearch/ts_type.h b/src/include/tsearch/ts_type.h index 0aa95e892c..107fc4a711 100644 --- a/src/include/tsearch/ts_type.h +++ b/src/include/tsearch/ts_type.h @@ -5,7 +5,7 @@ * * Copyright (c) 1998-2007, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/include/tsearch/ts_type.h,v 1.4 2007/09/07 16:03:40 teodor Exp $ + * $PostgreSQL: pgsql/src/include/tsearch/ts_type.h,v 1.5 2007/09/11 08:46:29 teodor Exp $ * *------------------------------------------------------------------------- */ @@ -43,6 +43,13 @@ typedef struct typedef uint16 WordEntryPos; +typedef struct +{ + uint16 npos; + WordEntryPos pos[1]; /* var length */ +} WordEntryPosVector; + + #define WEP_GETWEIGHT(x) ( (x) >> 14 ) #define WEP_GETPOS(x) ( (x) & 0x3fff ) @@ -88,9 +95,9 @@ typedef TSVectorData *TSVector; /* returns a pointer to the beginning of lexemes */ #define STRPTR(x) ( (char *) &(x)->entries[x->size] ) -#define _POSDATAPTR(x,e) (STRPTR(x) + SHORTALIGN((e)->pos + (e)->len)) -#define POSDATALEN(x,e) ( ( ((WordEntry*)(e))->haspos ) ? (*(uint16*)_POSDATAPTR(x,e)) : 0 ) -#define POSDATAPTR(x,e) ( (WordEntryPos*)( _POSDATAPTR(x,e)+sizeof(uint16) ) ) +#define _POSVECPTR(x, e) ((WordEntryPosVector *)(STRPTR(x) + SHORTALIGN((e)->pos + (e)->len))) +#define POSDATALEN(x,e) ( ( (e)->haspos ) ? (_POSVECPTR(x,e)->npos) : 0 ) +#define POSDATAPTR(x,e) (_POSVECPTR(x,e)->pos) /* * fmgr interface macros |