Re: [PATCH] Add pg_lfind8_nonzero()

Peter Eisentraut <peter@eisentraut.org>

From: Peter Eisentraut <peter@eisentraut.org>
To: cca5507 <cca5507@qq.com>, pgsql-hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-12-17T15:09:42Z
Lists: pgsql-hackers
On 14.12.25 14:33, cca5507 wrote:
> With pg_lfind8_nonzero(), we can write the code like this:
> 
> ```
> 	if (likely(numberOfAttributes > 0))
> 		hasnull = pg_lfind8_nonzero((uint8 *) isnull, numberOfAttributes);
> ```
> 
> The pg_lfind8_nonzero() is faster because we can handle 8 bool values at a time.

Maybe you could try popcount for this?

     hasnull = (pg_popcount((char *) isnull, numberOfAttributes) > 0);