Skip to content

Commit 37a6672

Browse files
committed
Remove unreferenced 'GPBMessageSignatureProtocol' class.
Remove unreferenced 'GPBMessageSignatureProtocol' class that is just taking up space in the Objective C runtime information by hanging the protocol it needs to declare off of GPBRootObject instead. Small binary size reduction, but more importantly a removal of a class that appears to be unused when statically analyzed.
1 parent 91ff83c commit 37a6672

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

objectivec/GPBRootObject.m

+8
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ @interface GPBExtensionDescriptor (GPBRootObject)
4343
- (const char *)singletonNameC;
4444
@end
4545

46+
// We need some object to conform to the MessageSignatureProtocol to make sure
47+
// the selectors in it are recorded in our Objective C runtime information.
48+
// GPBMessage is arguably the more "obvious" choice, but given that all messages
49+
// inherit from GPBMessage, conflicts seem likely, so we are using GPBRootObject
50+
// instead.
51+
@interface GPBRootObject () <GPBMessageSignatureProtocol>
52+
@end
53+
4654
@implementation GPBRootObject
4755

4856
// Taken from http://www.burtleburtle.net/bob/hash/doobs.html

objectivec/GPBUtilities.m

+3-10
Original file line numberDiff line numberDiff line change
@@ -1216,8 +1216,11 @@ void GPBSetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field,
12161216
const char *GPBMessageEncodingForSelector(SEL selector, BOOL instanceSel) {
12171217
Protocol *protocol =
12181218
objc_getProtocol(GPBStringifySymbol(GPBMessageSignatureProtocol));
1219+
NSCAssert(protocol, @"Missing GPBMessageSignatureProtocol");
12191220
struct objc_method_description description =
12201221
protocol_getMethodDescription(protocol, selector, NO, instanceSel);
1222+
NSCAssert(description.name != Nil && description.types != nil,
1223+
@"Missing method for selector %@", NSStringFromSelector(selector));
12211224
return description.types;
12221225
}
12231226

@@ -1911,13 +1914,3 @@ BOOL GPBClassHasSel(Class aClass, SEL sel) {
19111914
free(methodList);
19121915
return result;
19131916
}
1914-
1915-
#pragma mark - GPBMessageSignatureProtocol
1916-
1917-
// A series of selectors that are used solely to get @encoding values
1918-
// for them by the dynamic protobuf runtime code. An object using the protocol
1919-
// needs to be declared for the protocol to be valid at runtime.
1920-
@interface GPBMessageSignatureProtocol : NSObject<GPBMessageSignatureProtocol>
1921-
@end
1922-
@implementation GPBMessageSignatureProtocol
1923-
@end

objectivec/GPBUtilities_PackagePrivate.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,8 @@ NSString *GPBDecodeTextFormatName(const uint8_t *decodeData, int32_t key,
309309

310310
// A series of selectors that are used solely to get @encoding values
311311
// for them by the dynamic protobuf runtime code. See
312-
// GPBMessageEncodingForSelector for details.
312+
// GPBMessageEncodingForSelector for details. GPBRootObject conforms to
313+
// the protocol so that it is encoded in the Objective C runtime.
313314
@protocol GPBMessageSignatureProtocol
314315
@optional
315316

0 commit comments

Comments
 (0)