Exposes the currently registered extensions for a message and removes the internal sortedExtensionsInUse
diff --git a/objectivec/GPBMessage.h b/objectivec/GPBMessage.h
index 9608cdb..7e0f58a 100644
--- a/objectivec/GPBMessage.h
+++ b/objectivec/GPBMessage.h
@@ -275,6 +275,9 @@
/// 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 b9566bd..4a6f061 100644
--- a/objectivec/GPBMessage.m
+++ b/objectivec/GPBMessage.m
@@ -1777,11 +1777,6 @@
}
}
-- (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 ff3cd6e..02d0e16 100644
--- a/objectivec/GPBMessage_PackagePrivate.h
+++ b/objectivec/GPBMessage_PackagePrivate.h
@@ -78,10 +78,6 @@
// 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 0537508..ee84fb4 100644
--- a/objectivec/GPBUtilities.m
+++ b/objectivec/GPBUtilities.m
@@ -1472,7 +1472,8 @@
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(