diff --git a/src/backend/nodes/bitmapset.c b/src/backend/nodes/bitmapset.c
index b18b7a5..7b4d4db 100644
--- a/src/backend/nodes/bitmapset.c
+++ b/src/backend/nodes/bitmapset.c
@@ -634,17 +634,8 @@ bms_add_member(Bitmapset *a, int x)
 	bitnum = BITNUM(x);
 	if (wordnum >= a->nwords)
 	{
-		/* Slow path: make a larger set and union the input set into it */
-		Bitmapset  *result;
-		int			nwords;
-		int			i;
-
-		result = bms_make_singleton(x);
-		nwords = a->nwords;
-		for (i = 0; i < nwords; i++)
-			result->words[i] |= a->words[i];
-		pfree(a);
-		return result;
+		a = (Bitmapset *) repalloc(a, BITMAPSET_SIZE(wordnum + 1));
+		a->nwords = wordnum + 1;
 	}
 	/* Fast path: x fits in existing set */
 	a->words[wordnum] |= ((bitmapword) 1 << bitnum);
