Skip to content

Commit

Permalink
Use _deviceForNodeID:createIfNeeded: in more places. (project-chip#36602
Browse files Browse the repository at this point in the history
)

We had some manual lock-and-get code that can go away now.
  • Loading branch information
bzbarsky-apple authored Nov 22, 2024
1 parent 737c8f2 commit 04e6a68
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/darwin/Framework/CHIP/MTRDeviceController_Concrete.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1619,12 +1619,9 @@ - (void)invalidateCASESessionForNode:(NSNumber *)nodeID;

- (void)operationalInstanceAdded:(NSNumber *)nodeID
{
// Don't use deviceForNodeID here, because we don't want to create the
// device if it does not already exist.
os_unfair_lock_lock(self.deviceMapLock);
MTRDevice * device = [self.nodeIDToDeviceMap objectForKey:nodeID];
os_unfair_lock_unlock(self.deviceMapLock);

// If we don't have an existing MTRDevice for this node ID, that's fine;
// nothing to do.
MTRDevice * device = [self _deviceForNodeID:nodeID createIfNeeded:NO];
if (device == nil) {
return;
}
Expand Down

0 comments on commit 04e6a68

Please sign in to comment.