mirror of
https://github.com/postgres/postgres.git
synced 2025-08-21 10:42:50 +03:00
Remove bms_first_member().
This function has been semi-deprecated ever since we invented bms_next_member(). Its habit of scribbling on the input bitmapset isn't great, plus for sufficiently large bitmapsets it would take O(N^2) time to complete a loop. Now we have the additional problem that reducing the input to empty while leaving it still accessible would violate a planned invariant. So let's just get rid of it, after updating the few extant callers to use bms_next_member(). Patch by me; thanks to Nathan Bossart and Richard Guo for review. Discussion: https://postgr.es/m/1159933.1677621588@sss.pgh.pa.us
This commit is contained in:
@@ -982,48 +982,6 @@ bms_join(Bitmapset *a, Bitmapset *b)
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* bms_first_member - find and remove first member of a set
|
||||
*
|
||||
* Returns -1 if set is empty. NB: set is destructively modified!
|
||||
*
|
||||
* This is intended as support for iterating through the members of a set.
|
||||
* The typical pattern is
|
||||
*
|
||||
* while ((x = bms_first_member(inputset)) >= 0)
|
||||
* process member x;
|
||||
*
|
||||
* CAUTION: this destroys the content of "inputset". If the set must
|
||||
* not be modified, use bms_next_member instead.
|
||||
*/
|
||||
int
|
||||
bms_first_member(Bitmapset *a)
|
||||
{
|
||||
int nwords;
|
||||
int wordnum;
|
||||
|
||||
if (a == NULL)
|
||||
return -1;
|
||||
nwords = a->nwords;
|
||||
for (wordnum = 0; wordnum < nwords; wordnum++)
|
||||
{
|
||||
bitmapword w = a->words[wordnum];
|
||||
|
||||
if (w != 0)
|
||||
{
|
||||
int result;
|
||||
|
||||
w = RIGHTMOST_ONE(w);
|
||||
a->words[wordnum] &= ~w;
|
||||
|
||||
result = wordnum * BITS_PER_BITMAPWORD;
|
||||
result += bmw_rightmost_one_pos(w);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* bms_next_member - find next member of a set
|
||||
*
|
||||
|
Reference in New Issue
Block a user