mirror of
https://github.com/ppy/osu.git
synced 2025-01-30 01:32:55 +08:00
Trim comments
Leaving only the ones that add anything useful and do not restate the code verbatim.
This commit is contained in:
parent
27fabd99fb
commit
1d4d31e35c
@ -60,7 +60,7 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
SerialisedDrawableInfo[] skinnableInfos = deserializedContent.ToArray();
|
SerialisedDrawableInfo[] skinnableInfos = deserializedContent.ToArray();
|
||||||
ISerialisableDrawable[] targetComponents = firstTarget.Components.ToArray();
|
ISerialisableDrawable[] targetComponents = firstTarget.Components.ToArray();
|
||||||
|
|
||||||
// Store components based on type for later lookup
|
// Store components based on type for later reuse
|
||||||
var componentsPerTypeLookup = new Dictionary<Type, Queue<Drawable>>();
|
var componentsPerTypeLookup = new Dictionary<Type, Queue<Drawable>>();
|
||||||
|
|
||||||
foreach (ISerialisableDrawable component in targetComponents)
|
foreach (ISerialisableDrawable component in targetComponents)
|
||||||
@ -73,7 +73,6 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
componentsOfSameType.Enqueue((Drawable)component);
|
componentsOfSameType.Enqueue((Drawable)component);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove all components
|
|
||||||
for (int i = targetComponents.Length - 1; i >= 0; i--)
|
for (int i = targetComponents.Length - 1; i >= 0; i--)
|
||||||
firstTarget.Remove(targetComponents[i], false);
|
firstTarget.Remove(targetComponents[i], false);
|
||||||
|
|
||||||
@ -87,23 +86,22 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wherever possible, attempt to reuse existing component instances.
|
||||||
if (componentsOfSameType.TryDequeue(out Drawable? component))
|
if (componentsOfSameType.TryDequeue(out Drawable? component))
|
||||||
{
|
{
|
||||||
// Re-use unused component
|
|
||||||
component.ApplySerialisedInfo(skinnableInfo);
|
component.ApplySerialisedInfo(skinnableInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Create new one
|
|
||||||
component = skinnableInfo.CreateInstance();
|
component = skinnableInfo.CreateInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
firstTarget.Add((ISerialisableDrawable)component);
|
firstTarget.Add((ISerialisableDrawable)component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Dispose components which were not reused.
|
||||||
foreach ((Type _, Queue<Drawable> typeComponents) in componentsPerTypeLookup)
|
foreach ((Type _, Queue<Drawable> typeComponents) in componentsPerTypeLookup)
|
||||||
{
|
{
|
||||||
// Dispose extra components
|
|
||||||
foreach (var component in typeComponents)
|
foreach (var component in typeComponents)
|
||||||
component.Dispose();
|
component.Dispose();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user