aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/tsvector.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/adt/tsvector.c')
-rw-r--r--src/backend/utils/adt/tsvector.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/backend/utils/adt/tsvector.c b/src/backend/utils/adt/tsvector.c
index 650be842f28..1fa2e3729bf 100644
--- a/src/backend/utils/adt/tsvector.c
+++ b/src/backend/utils/adt/tsvector.c
@@ -25,7 +25,7 @@
typedef struct
{
- WordEntry entry; /* must be first! */
+ WordEntry entry; /* must be first, see compareentry */
WordEntryPos *pos;
int poslen; /* number of elements in pos */
} WordEntryIN;
@@ -79,16 +79,19 @@ uniquePos(WordEntryPos *a, int l)
return res + 1 - a;
}
-/* Compare two WordEntryIN values for qsort */
+/*
+ * Compare two WordEntry structs for qsort_arg. This can also be used on
+ * WordEntryIN structs, since those have WordEntry as their first field.
+ */
static int
compareentry(const void *va, const void *vb, void *arg)
{
- const WordEntryIN *a = (const WordEntryIN *) va;
- const WordEntryIN *b = (const WordEntryIN *) vb;
+ const WordEntry *a = (const WordEntry *) va;
+ const WordEntry *b = (const WordEntry *) vb;
char *BufferStr = (char *) arg;
- return tsCompareString(&BufferStr[a->entry.pos], a->entry.len,
- &BufferStr[b->entry.pos], b->entry.len,
+ return tsCompareString(&BufferStr[a->pos], a->len,
+ &BufferStr[b->pos], b->len,
false);
}
@@ -167,12 +170,6 @@ uniqueentry(WordEntryIN *a, int l, char *buf, int *outbuflen)
return res + 1 - a;
}
-static int
-WordEntryCMP(WordEntry *a, WordEntry *b, char *buf)
-{
- return compareentry(a, b, buf);
-}
-
Datum
tsvectorin(PG_FUNCTION_ARGS)
@@ -511,7 +508,7 @@ tsvectorrecv(PG_FUNCTION_ARGS)
datalen += lex_len;
- if (i > 0 && WordEntryCMP(&vec->entries[i],
+ if (i > 0 && compareentry(&vec->entries[i],
&vec->entries[i - 1],
STRPTR(vec)) <= 0)
needSort = true;