Skip to content

Use correct type for receivers that best matches its data #4720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions CoreFoundation/Base.subproj/CFSortFunctions.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ static void __CFSortIndexesNMerge(VALUE_TYPE listp1[], INDEX_TYPE cnt1, VALUE_TY
/* Merging algorithm based on
"A New Parallel Sorting Algorithm based on Odd-Even Mergesort", Ezequiel Herruzo, et al
*/
static void __CFSortIndexesN(VALUE_TYPE listp[], INDEX_TYPE count, int32_t ncores, CMP_RESULT_TYPE (^cmp)(INDEX_TYPE, INDEX_TYPE)) {
static void __CFSortIndexesN(VALUE_TYPE listp[], INDEX_TYPE count, INDEX_TYPE ncores, CMP_RESULT_TYPE (^cmp)(INDEX_TYPE, INDEX_TYPE)) {
/* Divide the array up into up to ncores, multiple-of-16-sized, chunks */
INDEX_TYPE sz = ((((count + ncores - 1) / ncores) + 15) / 16) * 16;
INDEX_TYPE sz = (((count + ncores - 1) / ncores) + 15) & ~15;
INDEX_TYPE num_sect = (count + sz - 1) / sz;
INDEX_TYPE last_sect_len = count + sz - sz * num_sect;

Expand Down Expand Up @@ -260,7 +260,7 @@ static void __CFSortIndexesN(VALUE_TYPE listp[], INDEX_TYPE count, int32_t ncore
INDEX_TYPE sect2_len = (sect + 1 + (right ? 1 : 2) == num_sect) ? last_sect_len : sz;
__CFSortIndexesNMerge(left_base, sz, right_base, sect2_len, listp + sect * sz + sz, right, cmp);
});
memmove(listp + 0 * sz, tmps[0], sz * sizeof(VALUE_TYPE));
memmove(listp, tmps[0], sz * sizeof(VALUE_TYPE));
if (!(num_sect & 0x1)) {
memmove(listp + (num_sect - 1) * sz, tmps[num_sect - 1], last_sect_len * sizeof(VALUE_TYPE));
}
Expand All @@ -285,7 +285,7 @@ _CF_SORT_INDEXES_EXPORT void CFSortIndexes(CFIndex *indexBuffer, CFIndex count,
CRSetCrashLogMessage("Size of array to be sorted is too big");
HALT;
}
int32_t ncores = 0;
CFIndex ncores = 0;
if (opts & kCFSortConcurrent) {
ncores = __CFActiveProcessorCount();
if (count < 160 || ncores < 2) {
Expand All @@ -307,7 +307,7 @@ _CF_SORT_INDEXES_EXPORT void CFSortIndexes(CFIndex *indexBuffer, CFIndex count,
} else {
/* Specifically hard-coded to 8; the count has to be very large before more chunks and/or cores is worthwhile. */
dispatch_queue_t q = dispatch_queue_create(__CF_QUEUE_NAME("NSSortIndexes"), DISPATCH_QUEUE_CONCURRENT);
CFIndex sz = ((((size_t)count + 15) / 16) * 16) / 8;
CFIndex sz = ((count + 15) >> 3) & ~1;
dispatch_apply(8, DISPATCH_APPLY_AUTO, ^(size_t n) {
CFIndex idx = n * sz, lim = __CFMin(idx + sz, count);
for (; idx < lim; idx++) indexBuffer[idx] = idx;
Expand Down
8 changes: 4 additions & 4 deletions CoreFoundation/Base.subproj/CFUUID.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ CFUUIDRef CFUUIDCreateWithBytes(CFAllocatorRef alloc, uint8_t byte0, uint8_t byt
return __CFUUIDCreateWithBytesPrimitive(alloc, bytes, false);
}

static void _intToHexChars(UInt32 in, UniChar *out, int digits) {
int shift;
static void _intToHexChars(UInt32 in, UniChar *out, unsigned int digits) {
unsigned int shift;
UInt32 d;

while (--digits >= 0) {
while (digits--) {
shift = digits << 2;
d = 0x0FL & (in >> shift);
if (d <= 9) {
Expand Down
6 changes: 3 additions & 3 deletions CoreFoundation/PlugIn.subproj/CFBundle_Binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ static char *_cleanedPathForPath(const char *curName) {
char *thePath = strdup(curName);
if (thePath) {
// We are going to process the buffer replacing all "/./" and "//" with "/"
CFIndex srcIndex = 0, dstIndex = 0;
CFIndex len = strlen(thePath);
size_t srcIndex = 0, dstIndex = 0;
size_t len = strlen(thePath);
for (srcIndex=0; srcIndex<len; srcIndex++) {
thePath[dstIndex] = thePath[srcIndex];
dstIndex++;
while (srcIndex < len-1 && thePath[srcIndex] == '/' && (thePath[srcIndex+1] == '/' || (thePath[srcIndex+1] == '.' && srcIndex < len-2 && thePath[srcIndex+2] == '/'))) srcIndex += (thePath[srcIndex+1] == '/' ? 1 : 2);
while (srcIndex + 1 < len && thePath[srcIndex] == '/' && (thePath[srcIndex+1] == '/' || (thePath[srcIndex+1] == '.' && srcIndex + 2 < len && thePath[srcIndex+2] == '/'))) srcIndex += (thePath[srcIndex+1] == '/' ? 1 : 2);
}
thePath[dstIndex] = 0;
}
Expand Down
15 changes: 8 additions & 7 deletions CoreFoundation/String.subproj/CFString.c
Original file line number Diff line number Diff line change
Expand Up @@ -1815,16 +1815,17 @@ static Boolean __cStrEqual(const void *ptr1, const void *ptr2) {
static CFHashCode __cStrHash(const void *ptr) {
// It doesn't quite matter if we convert to Unicode correctly, as long as we do it consistently
const char *cStr = (const char *)ptr;
CFIndex len = strlen(cStr);
size_t len = strlen(cStr);
CFHashCode result = 0;
if (len <= 4) { // All chars
unsigned cnt = len;
while (cnt--) result += (result << 8) + *cStr++;
for (size_t cnt = len; cnt; cnt--) {
result += (result << 8) | *cStr++;
}
} else { // First and last 2 chars
result += (result << 8) + cStr[0];
result += (result << 8) + cStr[1];
result += (result << 8) + cStr[len-2];
result += (result << 8) + cStr[len-1];
result += (result << 8) | cStr[0];
result += (result << 8) | cStr[1];
result += (result << 8) | cStr[len-2];
result += (result << 8) | cStr[len-1];
}
result += (result << (len & 31));
return result;
Expand Down
5 changes: 1 addition & 4 deletions CoreFoundation/String.subproj/CFStringTransform.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@ __CFStringTransformCreate(CFStringRef identifier, bool reverse) {
if (known) {
UniChar buff[kCFStringTransformStackBufferSize];
CFIndex len = strlen(known);
CFIndex idx;
for (idx = 0; idx < len; idx++) {
buff[idx] = known[idx];
}
memcpy(buff, known, len);
made = utrans_openU((const UChar *)buff, len, reverse?UTRANS_REVERSE:UTRANS_FORWARD, NULL, 0, NULL, &icuStatus);
} else {
CFIndex len = CFStringGetLength(identifier);
Expand Down