diff options
author | Thomas Van Lenten <thomasvl@google.com> | 2017-11-15 11:45:32 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-15 11:45:32 -0500 |
commit | 6552c5af3fa067778ec5fa2b65c6b4784f79e4b6 (patch) | |
tree | 404d68eb96ce7d1afe414fcb6485efe10c8d9150 /objectivec | |
parent | af5ad246176e6de8661b6a312a42c621c01736f5 (diff) | |
parent | 4ba30923fabfca78a0d8cbef8e153bd2fb83ad17 (diff) |
Merge pull request #3884 from dmaclach/unsafe
Simplify getter/setter method implementations
Diffstat (limited to 'objectivec')
-rw-r--r-- | objectivec/GPBMessage.m | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/objectivec/GPBMessage.m b/objectivec/GPBMessage.m index afe39c1e..90485bd1 100644 --- a/objectivec/GPBMessage.m +++ b/objectivec/GPBMessage.m @@ -2998,7 +2998,10 @@ typedef struct ResolveIvarAccessorMethodResult { SEL encodingSelector; } ResolveIvarAccessorMethodResult; -static void ResolveIvarGet(GPBFieldDescriptor *field, +// |field| can be __unsafe_unretained because they are created at startup +// and are essentially global. No need to pay for retain/release when +// they are captured in blocks. +static void ResolveIvarGet(__unsafe_unretained GPBFieldDescriptor *field, ResolveIvarAccessorMethodResult *result) { GPBDataType fieldDataType = GPBGetFieldDataType(field); switch (fieldDataType) { @@ -3040,7 +3043,8 @@ static void ResolveIvarGet(GPBFieldDescriptor *field, } } -static void ResolveIvarSet(GPBFieldDescriptor *field, +// See comment about __unsafe_unretained on ResolveIvarGet. +static void ResolveIvarSet(__unsafe_unretained GPBFieldDescriptor *field, GPBFileSyntax syntax, ResolveIvarAccessorMethodResult *result) { GPBDataType fieldDataType = GPBGetFieldDataType(field); @@ -3084,9 +3088,10 @@ static void ResolveIvarSet(GPBFieldDescriptor *field, // NOTE: hasOrCountSel_/setHasSel_ will be NULL if the field for the given // message should not have has support (done in GPBDescriptor.m), so there is // no need for checks here to see if has*/setHas* are allowed. - ResolveIvarAccessorMethodResult result = {NULL, NULL}; - for (GPBFieldDescriptor *field in descriptor->fields_) { + + // See comment about __unsafe_unretained on ResolveIvarGet. + for (__unsafe_unretained GPBFieldDescriptor *field in descriptor->fields_) { BOOL isMapOrArray = GPBFieldIsMapOrArray(field); if (!isMapOrArray) { // Single fields. |