@@ -1904,9 +1904,8 @@ - (void)_removeCachedAttribute:(NSNumber *)attributeID fromCluster:(MTRClusterPa
1904
1904
if (_clusterDataToPersist == nil) {
1905
1905
return;
1906
1906
}
1907
- auto * clusterData = [ _clusterDataToPersist objectForKey: clusterPath];
1907
+ auto * clusterData = _clusterDataToPersist[ clusterPath];
1908
1908
[clusterData removeValueForAttribute:attributeID];
1909
- [_clusterDataToPersist setObject:clusterData forKey:clusterPath];
1910
1909
}
1911
1910
1912
1911
- (void)_createDataVersionFilterListFromDictionary:(NSDictionary<MTRClusterPath *, NSNumber *> *)dataVersions dataVersionFilterList:(DataVersionFilter **)dataVersionFilterList count:(size_t *)count sizeReduction:(size_t)sizeReduction
@@ -3033,7 +3032,7 @@ - (BOOL)_attributeAffectsDeviceConfiguration:(MTRAttributePath *)attributePath
3033
3032
return NO;
3034
3033
}
3035
3034
3036
- - (void)_removeClusters:(NSSet *)clusterPathsToRemove
3035
+ - (void)_removeClusters:(NSSet<MTRClusterPath *> *)clusterPathsToRemove
3037
3036
{
3038
3037
os_unfair_lock_assert_owner(&self->_lock);
3039
3038
@@ -3047,7 +3046,7 @@ - (void)_removeClusters:(NSSet *)clusterPathsToRemove
3047
3046
}
3048
3047
}
3049
3048
3050
- - (void)_removeAttributes:(NSSet *)toBeRemovedAttributes fromCluster:(MTRClusterPath *)clusterPathToRemoveAttributesFrom
3049
+ - (void)_removeAttributes:(NSSet<NSNumber *> *)attributes fromCluster:(MTRClusterPath *)clusterPath
3051
3050
{
3052
3051
if (toBeRemovedAttributes == nil || clusterPathToRemoveAttributesFrom == nil) {
3053
3052
return;
@@ -3057,15 +3056,17 @@ - (void)_removeAttributes:(NSSet *)toBeRemovedAttributes fromCluster:(MTRCluster
3057
3056
for (NSNumber * attribute in toBeRemovedAttributes) {
3058
3057
[self _removeCachedAttribute:attribute fromCluster:clusterPathToRemoveAttributesFrom];
3059
3058
}
3059
+ // Just clear out the NSCache entry for this cluster, so we'll load it from storage as needed.
3060
3060
[_persistedClusterData removeObjectForKey:clusterPathToRemoveAttributesFrom];
3061
3061
[self.deviceController.controllerDataStore clearStoredClusterDataForNodeID:self.nodeID endpointID:clusterPathToRemoveAttributesFrom.endpoint clusterID:clusterPathToRemoveAttributesFrom.cluster];
3062
3062
}
3063
3063
3064
- - (void)_pruneOrphanedEndpoints :(NSDictionary *)previousPartsListValue
3065
- newPartsListValue :(NSDictionary *)newPartsListValue
3064
+ - (void)_pruneEndpointsIn :(NSDictionary *)previousPartsListValue
3065
+ missingFrom :(NSDictionary *)newPartsListValue
3066
3066
{
3067
- // If the parts list changed and one or more endpoints were removed, remove all the clusters in _persistedClusters, _persistedClusterData and _clusterDataToPersist for all those endpoints.
3068
- // Also remove it from the data store.
3067
+ // If the parts list changed and one or more endpoints were removed, remove all the
3068
+ // clusters for all those endpoints from our data structures.
3069
+ // Also remove those endpoints from the data store.
3069
3070
NSMutableSet * toBeRemovedEndpoints = [NSMutableSet setWithArray:[self arrayOfNumbersFromAttributeValue:[self _dataValueWithoutDataVersion:previousPartsListValue]]];
3070
3071
NSSet * endpointsOnDevice = [NSSet setWithArray:[self arrayOfNumbersFromAttributeValue:newPartsListValue]];
3071
3072
[toBeRemovedEndpoints minusSet:endpointsOnDevice];
@@ -3086,7 +3087,7 @@ - (void)_pruneOrphanedClusters:(MTRAttributePath *)attributePath
3086
3087
previousServerListValue:(NSDictionary *)previousServerListValue
3087
3088
newServerListValue:(NSDictionary *)newServerListValue
3088
3089
{
3089
- // If the server list changed and clusters were removed, remove the clusters from the _persistedClusters, _persistedClusterData and _clusterDataToPersist for all those clusters .
3090
+ // If the server list changed and clusters were removed, remove those clusters from our data structures .
3090
3091
// Also remove it from the data store.
3091
3092
NSMutableSet<NSNumber *> * toBeRemovedClusters = [NSMutableSet setWithArray:[self arrayOfNumbersFromAttributeValue:[self _dataValueWithoutDataVersion:previousServerListValue]]];
3092
3093
NSSet<NSNumber *> * clustersStillOnEndpoint = [NSSet setWithArray:[self arrayOfNumbersFromAttributeValue:newServerListValue]];
@@ -3106,8 +3107,8 @@ - (void)_pruneOrphanedClusters:(MTRAttributePath *)attributePath
3106
3107
- (void)_pruneOrphanedAttributes:(MTRAttributePath *)attributePath
3107
3108
newAttributeListValue:(NSDictionary *)newAttributeListValue
3108
3109
{
3109
- // If the attribute list changed and attributes were removed, remove the attributes from the _clusterDataToPersist for that cluster and endpoint.
3110
- // Clear out the _peristedClusterData and data store cluster data. Update the data storage with updated cluster data .
3110
+ // If the attribute list changed and attributes were removed, remove the attributes from our
3111
+ // data structures .
3111
3112
NSMutableSet<NSNumber *> * toBeRemovedAttributes = [NSMutableSet setWithArray:[self arrayOfNumbersFromAttributeValue:[self _cachedAttributeValueForPath:attributePath]]];
3112
3113
NSSet<NSNumber *> * attributesStillInCluster = [NSSet setWithArray:[self arrayOfNumbersFromAttributeValue:newAttributeListValue]];
3113
3114
@@ -3376,10 +3377,7 @@ - (BOOL)_clusterHasBeenPersisted:(MTRClusterPath *)path
3376
3377
{
3377
3378
std::lock_guard lock(_lock);
3378
3379
3379
- if ([_persistedClusters containsObject:path]) {
3380
- return YES;
3381
- }
3382
- return NO;
3380
+ return [_persistedClusters containsObject:path];
3383
3381
}
3384
3382
#endif
3385
3383
0 commit comments