From 2d71bb9285d6c745a7529e979236f0f0adcfefac 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. --- CoreFoundation/URL.subproj/CFURL.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/CoreFoundation/URL.subproj/CFURL.c b/CoreFoundation/URL.subproj/CFURL.c index 9b2dc82be8..b9294273fa 100644 --- a/CoreFoundation/URL.subproj/CFURL.c +++ b/CoreFoundation/URL.subproj/CFURL.c @@ -2381,13 +2381,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