Use _deviceForNodeID:createIfNeeded: in more places. (#36602)
We had some manual lock-and-get code that can go away now.
diff --git a/src/darwin/Framework/CHIP/MTRDeviceController_Concrete.mm b/src/darwin/Framework/CHIP/MTRDeviceController_Concrete.mm
index 4dfffcb..9939886 100644
--- a/src/darwin/Framework/CHIP/MTRDeviceController_Concrete.mm
+++ b/src/darwin/Framework/CHIP/MTRDeviceController_Concrete.mm
@@ -1619,12 +1619,9 @@
- (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;
}