From 0c44350badde61e554401591086d00db7d54561c Mon Sep 17 00:00:00 2001 From: Rose <83477269+AtariDreams@users.noreply.github.com> Date: Wed, 1 Nov 2023 15:05:30 -0400 Subject: [PATCH] Use popcount instead of manually counting bits This should work on Windows too as popcount is one of those intrinsics available on there as well. --- Sources/CoreFoundation/CFURL.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Sources/CoreFoundation/CFURL.c b/Sources/CoreFoundation/CFURL.c index a974ae1a67..371818dcf9 100644 --- a/Sources/CoreFoundation/CFURL.c +++ b/Sources/CoreFoundation/CFURL.c @@ -2375,13 +2375,7 @@ CFURLRef _CFURLCopyFileURL(CFURLRef url) // get just the component flag bits UInt32 flags = url->_flags & ALL_COMPONENTS_MASK; // get the rangeCount -- the number of component flag bits set - CFIndex rangeCount = 0; - while ( flags != 0 ) { - if ( flags & 1 ) { - ++rangeCount; - } - flags >>= 1; - } + CFIndex rangeCount = __builtin_popcount(flags); result = _CFURLAlloc(allocator, rangeCount); if ( result ) { // copy the URL fields from _flags to _ranges