优化缓存字典读取
This commit is contained in:
@@ -85,9 +85,9 @@ namespace SpineViewer.Spine.SpineView
|
||||
var props = new PropertyDescriptorCollection(TypeDescriptor.GetProperties(this, attributes, true).Cast<PropertyDescriptor>().ToArray());
|
||||
foreach (var i in Spine.GetTrackIndices())
|
||||
{
|
||||
if (!pdCache.ContainsKey(i))
|
||||
pdCache[i] = new TrackWrapperPropertyDescriptor(i, [new DisplayNameAttribute($"轨道 {i}")]);
|
||||
props.Add(pdCache[i]);
|
||||
if (!pdCache.TryGetValue(i, out var pd))
|
||||
pdCache[i] = pd = new TrackWrapperPropertyDescriptor(i, [new DisplayNameAttribute($"轨道 {i}")]);
|
||||
props.Add(pd);
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
@@ -53,9 +53,9 @@ namespace SpineViewer.Spine.SpineView
|
||||
var props = new PropertyDescriptorCollection(TypeDescriptor.GetProperties(this, attributes, true).Cast<PropertyDescriptor>().ToArray());
|
||||
foreach (var name in Spine.SkinNames)
|
||||
{
|
||||
if (!pdCache.ContainsKey(name))
|
||||
pdCache[name] = new SkinPropertyDescriptor(name, [new DisplayNameAttribute(name)]);
|
||||
props.Add(pdCache[name]);
|
||||
if (!pdCache.TryGetValue(name, out var pd))
|
||||
pdCache[name] = pd = new SkinPropertyDescriptor(name, [new DisplayNameAttribute(name)]);
|
||||
props.Add(pd);
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user