Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Boris Zbarsky <[email protected]>
  • Loading branch information
nivi-apple and bzbarsky-apple authored Apr 16, 2024
1 parent dfcfe9f commit 2eb1ad2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/darwin/Framework/CHIP/MTRDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2344,19 +2344,20 @@ - (NSArray *)_getAttributesToReportWithReportedValues:(NSArray<NSDictionary<NSSt
}
NSArray * expectedValue = _expectedValueCache[attributePath];

// Report the attribute if read attribute would get a value that is changing and no expected value exists.
// Report the attribute if a read would get a changed value. This happens
// when our cached value changes and no expected value exists.
if (readCacheValueChanged && !expectedValue) {
previousValue = _readCache[attributePath];
shouldReportAttribute = YES;
}

// Update the readCache with the attribute value.
// Now that we have grabbed previousValue, update the readCache with the attribute value.
_readCache[attributePath] = attributeDataValue;

if (!shouldReportAttribute) {

// If an expected value exists, the attribute will not be reported at this time.
// When the expected value interval expires, the correct value will be reported.
// When the expected value interval expires, the correct value will be reported,
// if needed.
if (expectedValue) {
MTR_LOG_INFO("%@ report %@ value filtered - expected value still present", self, attributePath);
} else
Expand Down

0 comments on commit 2eb1ad2

Please sign in to comment.