Skip to content

Commit a3a25ae

Browse files
committed
do not use typdef for struct which used once
1 parent 55e7037 commit a3a25ae

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

rum_ts_utils.c

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -520,14 +520,6 @@ rum_extract_tsquery(PG_FUNCTION_ARGS)
520520
PG_RETURN_POINTER(entries);
521521
}
522522

523-
typedef struct RestoreWordEntry
524-
{
525-
char *word;
526-
char *posptr;
527-
int32 npos;
528-
int32 wordlen;
529-
} RestoreWordEntry;
530-
531523
/*
532524
* reconstruct partial tsvector from set of index entries
533525
*/
@@ -540,15 +532,21 @@ rum_reconstruct_tsvector(bool *check, TSQuery query, int *map_item_operand,
540532
int i = 0;
541533
QueryItem *item = GETQUERY(query);
542534
char *operandData = GETOPERAND(query);
543-
RestoreWordEntry *rwe;
535+
struct
536+
{
537+
char *word;
538+
char *posptr;
539+
int32 npos;
540+
int32 wordlen;
541+
} *restoredWordEntry;
544542
int len = 0, totallen;
545543
bool *visited;
546544
WordEntry *ptr;
547545
char *str;
548546
int stroff;
549547

550548

551-
rwe = palloc(sizeof(*rwe) * query->size);
549+
restoredWordEntry = palloc(sizeof(*restoredWordEntry) * query->size);
552550
visited = palloc0(sizeof(*visited) * query->size);
553551

554552
/*
@@ -570,26 +568,26 @@ rum_reconstruct_tsvector(bool *check, TSQuery query, int *map_item_operand,
570568
*/
571569
visited[keyN] = true;
572570

573-
rwe[cntwords].word = operandData + item->qoperand.distance;
574-
rwe[cntwords].wordlen = item->qoperand.length;
571+
restoredWordEntry[cntwords].word = operandData + item->qoperand.distance;
572+
restoredWordEntry[cntwords].wordlen = item->qoperand.length;
575573

576574
len += item->qoperand.length;
577575

578576
if (addInfoIsNull[keyN] == false)
579577
{
580578
bytea *positions = DatumGetByteaP(addInfo[keyN]);
581579

582-
rwe[cntwords].npos = count_pos(VARDATA_ANY(positions),
580+
restoredWordEntry[cntwords].npos = count_pos(VARDATA_ANY(positions),
583581
VARSIZE_ANY_EXHDR(positions));
584-
rwe[cntwords].posptr = VARDATA_ANY(positions);
582+
restoredWordEntry[cntwords].posptr = VARDATA_ANY(positions);
585583

586584
len = SHORTALIGN(len);
587585
len += sizeof(uint16) +
588-
rwe[cntwords].npos * sizeof(WordEntryPos);
586+
restoredWordEntry[cntwords].npos * sizeof(WordEntryPos);
589587
}
590588
else
591589
{
592-
rwe[cntwords].npos = 0;
590+
restoredWordEntry[cntwords].npos = 0;
593591
}
594592

595593
cntwords++;
@@ -609,12 +607,12 @@ rum_reconstruct_tsvector(bool *check, TSQuery query, int *map_item_operand,
609607

610608
for (i=0; i<cntwords; i++)
611609
{
612-
ptr->len = rwe[i].wordlen;
610+
ptr->len = restoredWordEntry[i].wordlen;
613611
ptr->pos = stroff;
614-
memcpy(str + stroff, rwe[i].word, ptr->len);
612+
memcpy(str + stroff, restoredWordEntry[i].word, ptr->len);
615613
stroff += ptr->len;
616614

617-
if (rwe[i].npos)
615+
if (restoredWordEntry[i].npos)
618616
{
619617
WordEntryPos *wptr,
620618
post = 0;
@@ -623,15 +621,15 @@ rum_reconstruct_tsvector(bool *check, TSQuery query, int *map_item_operand,
623621
ptr->haspos = 1;
624622

625623
stroff = SHORTALIGN(stroff);
626-
*(uint16 *) (str + stroff) = rwe[i].npos;
624+
*(uint16 *) (str + stroff) = restoredWordEntry[i].npos;
627625
wptr = POSDATAPTR(tsv, ptr);
628626

629-
for (j=0; j<rwe[i].npos; j++)
627+
for (j=0; j<restoredWordEntry[i].npos; j++)
630628
{
631-
rwe[i].posptr = decompress_pos(rwe[i].posptr, &post);
629+
restoredWordEntry[i].posptr = decompress_pos(restoredWordEntry[i].posptr, &post);
632630
wptr[j] = post;
633631
}
634-
stroff += sizeof(uint16) + rwe[i].npos * sizeof(WordEntryPos);
632+
stroff += sizeof(uint16) + restoredWordEntry[i].npos * sizeof(WordEntryPos);
635633
}
636634
else
637635
{
@@ -641,7 +639,7 @@ rum_reconstruct_tsvector(bool *check, TSQuery query, int *map_item_operand,
641639
ptr++;
642640
}
643641

644-
pfree(rwe);
642+
pfree(restoredWordEntry);
645643
pfree(visited);
646644

647645
return tsv;

0 commit comments

Comments
 (0)