Rename variables for legibility

Having `typedComponents` and `typeComponents` next to each other is
asking for trouble.
This commit is contained in:
Bartłomiej Dach
2023-05-03 19:21:16 +02:00
parent 4d52ce769b
commit 27fabd99fb

View File

@ -61,16 +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, Queue<Drawable>>(); var componentsPerTypeLookup = new Dictionary<Type, Queue<Drawable>>();
foreach (ISerialisableDrawable component in targetComponents) foreach (ISerialisableDrawable component in targetComponents)
{ {
Type lookup = component.GetType(); Type lookup = component.GetType();
if (!typedComponents.TryGetValue(lookup, out Queue<Drawable>? typeComponents)) if (!componentsPerTypeLookup.TryGetValue(lookup, out Queue<Drawable>? componentsOfSameType))
typedComponents.Add(lookup, typeComponents = new Queue<Drawable>()); componentsPerTypeLookup.Add(lookup, componentsOfSameType = new Queue<Drawable>());
typeComponents.Enqueue((Drawable)component); componentsOfSameType.Enqueue((Drawable)component);
} }
// Remove all components // Remove all components
@ -81,13 +81,13 @@ namespace osu.Game.Overlays.SkinEditor
{ {
Type lookup = skinnableInfo.Type; Type lookup = skinnableInfo.Type;
if (!typedComponents.TryGetValue(lookup, out Queue<Drawable>? typeComponents)) if (!componentsPerTypeLookup.TryGetValue(lookup, out Queue<Drawable>? componentsOfSameType))
{ {
firstTarget.Add((ISerialisableDrawable)skinnableInfo.CreateInstance()); firstTarget.Add((ISerialisableDrawable)skinnableInfo.CreateInstance());
continue; continue;
} }
if (typeComponents.TryDequeue(out Drawable? component)) if (componentsOfSameType.TryDequeue(out Drawable? component))
{ {
// Re-use unused component // Re-use unused component
component.ApplySerialisedInfo(skinnableInfo); component.ApplySerialisedInfo(skinnableInfo);
@ -101,7 +101,7 @@ namespace osu.Game.Overlays.SkinEditor
firstTarget.Add((ISerialisableDrawable)component); firstTarget.Add((ISerialisableDrawable)component);
} }
foreach ((Type _, Queue<Drawable> typeComponents) in typedComponents) foreach ((Type _, Queue<Drawable> typeComponents) in componentsPerTypeLookup)
{ {
// Dispose extra components // Dispose extra components
foreach (var component in typeComponents) foreach (var component in typeComponents)