summaryrefslogtreecommitdiff
path: root/src/backend/nodes/outfuncs.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2014-11-28 13:37:25 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2014-11-28 13:37:25 -0500
commitf4e031c662a6b600b786c4849968a099c58fcce7 (patch)
tree6a082f889ff2ea5b64bb43c467760686e5f013b0 /src/backend/nodes/outfuncs.c
parent96d66bcfc60d9bcb7db767f23d33abf4d8bc7021 (diff)
Add bms_next_member(), and use it where appropriate.
This patch adds a way of iterating through the members of a bitmapset nondestructively, unlike the old way with bms_first_member(). While bms_next_member() is very slightly slower than bms_first_member() (at least for typical-size bitmapsets), eliminating the need to palloc and pfree a temporary copy of the target bitmapset is a significant win. So this method should be preferred in all cases where a temporary copy would be necessary. Tom Lane, with suggestions from Dean Rasheed and David Rowley
Diffstat (limited to 'src/backend/nodes/outfuncs.c')
-rw-r--r--src/backend/nodes/outfuncs.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index ca9bd4f7c7f..edbd09f9425 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -184,15 +184,13 @@ _outList(StringInfo str, const List *node)
static void
_outBitmapset(StringInfo str, const Bitmapset *bms)
{
- Bitmapset *tmpset;
int x;
appendStringInfoChar(str, '(');
appendStringInfoChar(str, 'b');
- tmpset = bms_copy(bms);
- while ((x = bms_first_member(tmpset)) >= 0)
+ x = -1;
+ while ((x = bms_next_member(bms, x)) >= 0)
appendStringInfo(str, " %d", x);
- bms_free(tmpset);
appendStringInfoChar(str, ')');
}