mirror of
https://github.com/osukey/osukey.git
synced 2025-05-15 18:47:33 +09:00
Use Queue
instead of Stack
This commit is contained in:
parent
8f02bd80f9
commit
fb4b681cc5
@ -61,17 +61,16 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
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 lookup
|
||||||
var typedComponents = new Dictionary<Type, Stack<Drawable>>();
|
var typedComponents = new Dictionary<Type, Queue<Drawable>>();
|
||||||
|
|
||||||
for (int i = targetComponents.Length - 1; i >= 0; i--)
|
foreach (ISerialisableDrawable component in targetComponents)
|
||||||
{
|
{
|
||||||
Drawable component = (Drawable)targetComponents[i];
|
|
||||||
Type lookup = component.GetType();
|
Type lookup = component.GetType();
|
||||||
|
|
||||||
if (!typedComponents.TryGetValue(lookup, out Stack<Drawable>? typeComponents))
|
if (!typedComponents.TryGetValue(lookup, out Queue<Drawable>? typeComponents))
|
||||||
typedComponents.Add(lookup, typeComponents = new Stack<Drawable>());
|
typedComponents.Add(lookup, typeComponents = new Queue<Drawable>());
|
||||||
|
|
||||||
typeComponents.Push(component);
|
typeComponents.Enqueue((Drawable)component);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove all components
|
// Remove all components
|
||||||
@ -82,13 +81,13 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
{
|
{
|
||||||
Type lookup = skinnableInfo.Type;
|
Type lookup = skinnableInfo.Type;
|
||||||
|
|
||||||
if (!typedComponents.TryGetValue(lookup, out Stack<Drawable>? typeComponents))
|
if (!typedComponents.TryGetValue(lookup, out Queue<Drawable>? typeComponents))
|
||||||
{
|
{
|
||||||
firstTarget.Add((ISerialisableDrawable)skinnableInfo.CreateInstance());
|
firstTarget.Add((ISerialisableDrawable)skinnableInfo.CreateInstance());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeComponents.TryPop(out Drawable? component))
|
if (typeComponents.TryDequeue(out Drawable? component))
|
||||||
{
|
{
|
||||||
// Re-use unused component
|
// Re-use unused component
|
||||||
component.ApplySerialisedInfo(skinnableInfo);
|
component.ApplySerialisedInfo(skinnableInfo);
|
||||||
@ -102,7 +101,7 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
firstTarget.Add((ISerialisableDrawable)component);
|
firstTarget.Add((ISerialisableDrawable)component);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ((Type _, Stack<Drawable> typeComponents) in typedComponents)
|
foreach ((Type _, Queue<Drawable> typeComponents) in typedComponents)
|
||||||
{
|
{
|
||||||
// Dispose extra components
|
// Dispose extra components
|
||||||
foreach (var component in typeComponents)
|
foreach (var component in typeComponents)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user