vis: replace ffsl with std::countr_zero

This commit is contained in:
Eric Wasylishen 2023-07-08 20:04:05 -06:00
parent 2637a5fb65
commit f28522a077
1 changed files with 2 additions and 17 deletions

View File

@ -2,6 +2,7 @@
#include <climits>
#include <cstdint>
#include <bit> // for std::countr_zero
#include <vis/leafbits.hh>
#include <vis/vis.hh>
@ -11,22 +12,6 @@
#include <common/parallel.hh>
#include <fmt/chrono.h>
/* Use some GCC builtins */
#if !defined(ffsl) && defined(__GNUC__)
#define ffsl __builtin_ffsl
#elif defined(_WIN32)
#include <intrin.h>
inline int ffsl(long int val)
{
unsigned long indexout;
unsigned char res = _BitScanForward(&indexout, val);
if (!res)
return 0;
else
return indexout + 1;
}
#endif
/*
* If the portal file is "PRT2" format, then the leafs we are dealing with are
* really clusters of leaves. So, after the vis job is done we need to expand
@ -357,7 +342,7 @@ static void PortalCompleted(visportal_t *completed)
* Update mightsee for any of the changed bits that survived
*/
while (changed) {
bit = ffsl(changed) - 1;
bit = std::countr_zero(changed);
changed &= ~nth_bit(bit);
leafnum = (j << leafbits_t::shift) + bit;
UpdateMightsee(leafs[leafnum], myleaf);