Skip to content

Commit

Permalink
Address some review comments on Darwin controller data store. (#29003)
Browse files Browse the repository at this point in the history
1) More efficient copying of arrays.
2) Make it clear what classes need to go in our storage class list.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Mar 15, 2024
1 parent 966d7fb commit 55b8559
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/darwin/Framework/CHIP/MTRDeviceControllerDataStore.mm
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ - (nullable instancetype)initWithController:(MTRDeviceController *)controller
return nil;
}
}
_nodesWithResumptionInfo = [NSMutableArray arrayWithCapacity:[resumptionNodeList count]];
[_nodesWithResumptionInfo addObjectsFromArray:resumptionNodeList];
_nodesWithResumptionInfo = [resumptionNodeList mutableCopy];
} else {
_nodesWithResumptionInfo = [[NSMutableArray alloc] init];
}
Expand Down Expand Up @@ -184,7 +183,7 @@ - (void)storeResumptionInfo:(MTRCASESessionResumptionInfo *)resumptionInfo
// Update our resumption info node list.
[_nodesWithResumptionInfo addObject:resumptionInfo.nodeID];
[_storageDelegate controller:_controller
storeValue:[NSArray arrayWithArray:_nodesWithResumptionInfo]
storeValue:[_nodesWithResumptionInfo copy]
forKey:sResumptionNodeListKey
securityLevel:MTRStorageSecurityLevelSecure
sharingType:MTRStorageSharingTypeNotShared];
Expand Down Expand Up @@ -349,6 +348,9 @@ - (void)encodeWithCoder:(NSCoder *)coder

NSSet<Class> * MTRDeviceControllerStorageClasses()
{
// This only needs to return the classes for toplevel things we are storing,
// plus NSNumber because some archivers use that internally to store
// information about what's being archived.
static NSSet * const sStorageClasses = [NSSet setWithArray:@[
[NSNumber class],
[NSData class],
Expand Down

0 comments on commit 55b8559

Please sign in to comment.