1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 16:02:58 +08:00

Reduce memory allocations in MenuCursorContainer

This commit is contained in:
Dean Herbert 2020-07-19 11:37:10 +09:00
parent fb5a54d242
commit 72ace508b6

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
@ -55,7 +54,15 @@ namespace osu.Game.Graphics.Cursor
return;
}
var newTarget = inputManager.HoveredDrawables.OfType<IProvideCursor>().FirstOrDefault(t => t.ProvidingUserCursor) ?? this;
IProvideCursor newTarget = this;
foreach (var d in inputManager.HoveredDrawables)
{
if (!(d is IProvideCursor p) || !p.ProvidingUserCursor) continue;
newTarget = p;
break;
}
if (currentTarget == newTarget)
return;