@@ -540,14 +540,12 @@ rum_reconstruct_tsvector(bool *check, TSQuery query, int *map_item_operand,
540
540
int32 wordlen ;
541
541
}* restoredWordEntry ;
542
542
int len = 0 ,totallen ;
543
- bool * visited ;
544
543
WordEntry * ptr ;
545
544
char * str ;
546
545
int stroff ;
547
546
548
547
549
548
restoredWordEntry = palloc (sizeof (* restoredWordEntry )* query -> size );
550
- visited = palloc0 (sizeof (* visited )* query -> size );
551
549
552
550
/*
553
551
* go through query to collect lexemes and add to them
@@ -560,13 +558,13 @@ rum_reconstruct_tsvector(bool *check, TSQuery query, int *map_item_operand,
560
558
{
561
559
int keyN = map_item_operand [i ];
562
560
563
- if (check [keyN ]== true&& visited [ keyN ] == false )
561
+ if (check [keyN ]== true)
564
562
{
565
563
/*
566
564
* entries could be repeated in tsquery, do not visit them twice
567
- * or more
565
+ * or more. Modifying of check array (entryRes) is safe
568
566
*/
569
- visited [keyN ]= true ;
567
+ check [keyN ]= false ;
570
568
571
569
restoredWordEntry [cntwords ].word = operandData + item -> qoperand .distance ;
572
570
restoredWordEntry [cntwords ].wordlen = item -> qoperand .length ;
@@ -640,7 +638,6 @@ rum_reconstruct_tsvector(bool *check, TSQuery query, int *map_item_operand,
640
638
}
641
639
642
640
pfree (restoredWordEntry );
643
- pfree (visited );
644
641
645
642
return tsv ;
646
643
}