From f4e031c662a6b600b786c4849968a099c58fcce7 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 28 Nov 2014 13:37:25 -0500 Subject: 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 --- src/backend/optimizer/path/allpaths.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/backend/optimizer/path/allpaths.c') diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c index 25f30676f0..449fdc3474 100644 --- a/src/backend/optimizer/path/allpaths.c +++ b/src/backend/optimizer/path/allpaths.c @@ -2272,19 +2272,17 @@ remove_unused_subquery_outputs(Query *subquery, RelOptInfo *rel) static void print_relids(Relids relids) { - Relids tmprelids; int x; bool first = true; - tmprelids = bms_copy(relids); - while ((x = bms_first_member(tmprelids)) >= 0) + x = -1; + while ((x = bms_next_member(relids, x)) >= 0) { if (!first) printf(" "); printf("%d", x); first = false; } - bms_free(tmprelids); } static void -- cgit v1.2.1