From 24d28e68a5d0302ed39a8455e3e1ca4b13e81920 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Wed, 12 Jun 2024 19:51:25 +1000 Subject: [PATCH] remove duplicate dictionary lookup --- Chickensoft.Serialization/src/SerializableBlackboard.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Chickensoft.Serialization/src/SerializableBlackboard.cs b/Chickensoft.Serialization/src/SerializableBlackboard.cs index 88b106f..bd0b4f5 100644 --- a/Chickensoft.Serialization/src/SerializableBlackboard.cs +++ b/Chickensoft.Serialization/src/SerializableBlackboard.cs @@ -133,8 +133,8 @@ protected override object GetBlackboardData(Type type) { // If it is a persisted type that isn't on the blackboard yet, we can // create an instance of the data and add it. - if (_saveTypes.ContainsKey(type)) { - data = _saveTypes[type](); + if (_saveTypes.TryGetValue(type, out var saveType)) { + data = saveType(); _blackboard[type] = data; return data; }