Skip to content

Commit 5904279

Browse files
committed
Remove the custom key functions and just use the system provided defaults.
1 parent b5bbdb0 commit 5904279

File tree

1 file changed

+3
-40
lines changed

1 file changed

+3
-40
lines changed

objectivec/GPBUnknownFieldSet.m

+3-40
Original file line numberDiff line numberDiff line change
@@ -36,39 +36,6 @@
3636
#import "GPBUtilities.h"
3737
#import "GPBWireFormat.h"
3838

39-
#pragma mark CFDictionaryKeyCallBacks
40-
41-
// We use a custom dictionary here because our keys are numbers and
42-
// conversion back and forth from NSNumber was costing us performance.
43-
// If/when we move to C++ this could be done using a std::map and some
44-
// careful retain/release calls.
45-
46-
static const void *GPBUnknownFieldSetKeyRetain(CFAllocatorRef allocator,
47-
const void *value) {
48-
#pragma unused(allocator)
49-
return value;
50-
}
51-
52-
static void GPBUnknownFieldSetKeyRelease(CFAllocatorRef allocator,
53-
const void *value) {
54-
#pragma unused(allocator)
55-
#pragma unused(value)
56-
}
57-
58-
static CFStringRef GPBUnknownFieldSetCopyKeyDescription(const void *value) {
59-
return CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%d"),
60-
(int)value);
61-
}
62-
63-
static Boolean GPBUnknownFieldSetKeyEqual(const void *value1,
64-
const void *value2) {
65-
return value1 == value2;
66-
}
67-
68-
static CFHashCode GPBUnknownFieldSetKeyHash(const void *value) {
69-
return (CFHashCode)value;
70-
}
71-
7239
#pragma mark Helpers
7340

7441
static void checkNumber(int32_t number) {
@@ -291,13 +258,9 @@ - (void)addField:(GPBUnknownField *)field {
291258
int32_t number = [field number];
292259
checkNumber(number);
293260
if (!fields_) {
294-
CFDictionaryKeyCallBacks keyCallBacks = {
295-
// See description above for reason for using custom dictionary.
296-
0, GPBUnknownFieldSetKeyRetain, GPBUnknownFieldSetKeyRelease,
297-
GPBUnknownFieldSetCopyKeyDescription, GPBUnknownFieldSetKeyEqual,
298-
GPBUnknownFieldSetKeyHash,
299-
};
300-
fields_ = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &keyCallBacks,
261+
// Use a custom dictionary here because the keys are numbers and conversion
262+
// back and forth from NSNumber isn't worth the cost.
263+
fields_ = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, NULL,
301264
&kCFTypeDictionaryValueCallBacks);
302265
}
303266
ssize_t key = number;

0 commit comments

Comments
 (0)