Closed nostek closed 1 year ago
Sorry for the delay. I tested your changes and it gave me some errors in Unity 2020.3.7f1
Assets\Submodules\xNode\Scripts\NodeDataCache.cs(40,29): error CS1061: 'Dictionary<string, NodePort>' does not contain a definition for 'EnsureCapacity' and no accessible extension method 'EnsureCapacity' accepting a first argument of type 'Dictionary<string, NodePort>' could be found (are you missing a using directive or an assembly reference?)
Sorry for the delay. I tested your changes and it gave me some errors in Unity 2020.3.7f1
Assets\Submodules\xNode\Scripts\NodeDataCache.cs(40,29): error CS1061: 'Dictionary<string, NodePort>' does not contain a definition for 'EnsureCapacity' and no accessible extension method 'EnsureCapacity' accepting a first argument of type 'Dictionary<string, NodePort>' could be found (are you missing a using directive or an assembly reference?)
My bad! Thought EnsureCapacity had existed for a while.. added ifdef guards around then. The function is introduced in net standard 2.1 https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2.ensurecapacity?view=net-7.0 And Unity upgraded to 2.1 in 2021.3.
I cant see why PortDataCache needs to be serialized, so I removed that and prefilled it with dictionaries instead of generating them in UpdatePorts.
Thanks! 😄
A few memory and gc optimizations that only makes a difference when you have a larger project, but does indeed make a difference.