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