diff --git a/objectivec/GPBMessage.h b/objectivec/GPBMessage.h index 9608cdb0..7e0f58a3 100644 --- a/objectivec/GPBMessage.h +++ b/objectivec/GPBMessage.h @@ -275,6 +275,9 @@ CF_EXTERN_C_END /// Return the descriptor for the message. - (GPBDescriptor *)descriptor; +/// Returns an array with the currently set GPBExtensionDescriptors. +- (NSArray *)extensionsCurrentlySet; + /// Test to see if the given extension is set on the message. - (BOOL)hasExtension:(GPBExtensionDescriptor *)extension; diff --git a/objectivec/GPBMessage.m b/objectivec/GPBMessage.m index b9566bdf..4a6f0612 100644 --- a/objectivec/GPBMessage.m +++ b/objectivec/GPBMessage.m @@ -1777,11 +1777,6 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) { } } -- (NSArray *)sortedExtensionsInUse { - return [[extensionMap_ allKeys] - sortedArrayUsingSelector:@selector(compareByFieldNumber:)]; -} - - (void)setExtension:(GPBExtensionDescriptor *)extension value:(id)value { if (!value) { [self clearExtension:extension]; diff --git a/objectivec/GPBMessage_PackagePrivate.h b/objectivec/GPBMessage_PackagePrivate.h index ff3cd6eb..02d0e16e 100644 --- a/objectivec/GPBMessage_PackagePrivate.h +++ b/objectivec/GPBMessage_PackagePrivate.h @@ -78,10 +78,6 @@ typedef struct GPBMessage_Storage *GPBMessage_StoragePtr; // returns nil if the extension is not set) - (id)getExistingExtension:(GPBExtensionDescriptor *)extension; -// Returns an array of GPBExtensionDescriptor* for all the extensions currently -// in use on the message. They are sorted by field number. -- (NSArray *)sortedExtensionsInUse; - // Parses a message of this type from the input and merges it with this // message. // diff --git a/objectivec/GPBUtilities.m b/objectivec/GPBUtilities.m index 05375084..ee84fb45 100644 --- a/objectivec/GPBUtilities.m +++ b/objectivec/GPBUtilities.m @@ -1472,7 +1472,8 @@ static void AppendTextFormatForMessage(GPBMessage *message, NSUInteger fieldCount = fieldsArray.count; const GPBExtensionRange *extensionRanges = descriptor.extensionRanges; NSUInteger extensionRangesCount = descriptor.extensionRangesCount; - NSArray *activeExtensions = [message sortedExtensionsInUse]; + NSArray *activeExtensions = [[message extensionsCurrentlySet] + sortedArrayUsingSelector:@selector(compareByFieldNumber:)]; for (NSUInteger i = 0, j = 0; i < fieldCount || j < extensionRangesCount;) { if (i == fieldCount) { AppendTextFormatForMessageExtensionRange(