|
36 | 36 | #import "GPBUtilities.h"
|
37 | 37 | #import "GPBWireFormat.h"
|
38 | 38 |
|
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 |
| - |
72 | 39 | #pragma mark Helpers
|
73 | 40 |
|
74 | 41 | static void checkNumber(int32_t number) {
|
@@ -291,13 +258,9 @@ - (void)addField:(GPBUnknownField *)field {
|
291 | 258 | int32_t number = [field number];
|
292 | 259 | checkNumber(number);
|
293 | 260 | 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, |
301 | 264 | &kCFTypeDictionaryValueCallBacks);
|
302 | 265 | }
|
303 | 266 | ssize_t key = number;
|
|
0 commit comments