diff options
author | Teodor Sigaev <teodor@sigaev.ru> | 2007-09-11 08:46:29 +0000 |
---|---|---|
committer | Teodor Sigaev <teodor@sigaev.ru> | 2007-09-11 08:46:29 +0000 |
commit | 57cafe79823dcd3653cf5e19cbdf58300cb1576c (patch) | |
tree | 8616fa0d0c77fd151cf874184fa5f21f56717aef /src/backend/utils/adt/tsgistidx.c | |
parent | ef4d38c86c1b1f834bd70115fd19f03431573c2d (diff) | |
download | postgresql-57cafe79823dcd3653cf5e19cbdf58300cb1576c.tar.gz |
Refactor from Heikki Linnakangas <heikki@enterprisedb.com>:
* 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/backend/utils/adt/tsgistidx.c')
-rw-r--r-- | src/backend/utils/adt/tsgistidx.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/backend/utils/adt/tsgistidx.c b/src/backend/utils/adt/tsgistidx.c index 4fc51378b4..985b917d0f 100644 --- a/src/backend/utils/adt/tsgistidx.c +++ b/src/backend/utils/adt/tsgistidx.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/tsgistidx.c,v 1.3 2007/09/07 15:09:56 teodor Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/tsgistidx.c,v 1.4 2007/09/11 08:46:29 teodor Exp $ * *------------------------------------------------------------------------- */ @@ -133,20 +133,27 @@ gtsvectorout(PG_FUNCTION_ARGS) } static int -compareint(const void *a, const void *b) +compareint(const void *va, const void *vb) { - if (*((int4 *) a) == *((int4 *) b)) + int4 a = *((int4 *) va); + int4 b = *((int4 *) vb); + + if (a == b) return 0; - return (*((int4 *) a) > *((int4 *) b)) ? 1 : -1; + return (a > b) ? 1 : -1; } +/* + * Removes duplicates from an array of int4. 'l' is + * size of the input array. Returns the new size of the array. + */ static int uniqueint(int4 *a, int4 l) { int4 *ptr, *res; - if (l == 1) + if (l <= 1) return l; ptr = res = a; @@ -570,12 +577,15 @@ typedef struct } SPLITCOST; static int -comparecost(const void *a, const void *b) +comparecost(const void *va, const void *vb) { - if (((SPLITCOST *) a)->cost == ((SPLITCOST *) b)->cost) + SPLITCOST *a = (SPLITCOST *) va; + SPLITCOST *b = (SPLITCOST *) vb; + + if (a->cost == b->cost) return 0; else - return (((SPLITCOST *) a)->cost > ((SPLITCOST *) b)->cost) ? 1 : -1; + return (a->cost > b->cost) ? 1 : -1; } |