From d9f052efeb726dc049a9a3b47e8c7e77c89f2ee1 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 20 Jul 2024 15:10:40 +0800 Subject: [PATCH] HasFlagFast() is imported in the 3 years ago: https://github.com/karaoke-dev/karaoke/pull/967 And it's removed in this update due to HasFlag() is faster than HasFlagFast(): https://github.com/karaoke-dev/karaoke/issues/2250 --- CodeAnalysis/BannedSymbols.txt | 1 - .../Sprites/Processor/DisplayProcessorTestScene.cs | 5 ++--- .../Edit/Components/Sprites/DrawableLayoutPreview.cs | 9 ++++----- .../Graphics/Sprites/DisplayLyricProcessor.cs | 5 ++--- .../Graphics/Sprites/Processor/BaseDisplayProcessor.cs | 5 ++--- .../Beatmaps/Lyrics/Content/Compose/LyricComposer.cs | 3 +-- .../Skinning/Elements/LyricLayout.cs | 9 ++++----- .../UI/HUD/SettingButtonsDisplay.cs | 3 +-- 8 files changed, 16 insertions(+), 24 deletions(-) diff --git a/CodeAnalysis/BannedSymbols.txt b/CodeAnalysis/BannedSymbols.txt index b72df0a30..760c41f14 100644 --- a/CodeAnalysis/BannedSymbols.txt +++ b/CodeAnalysis/BannedSymbols.txt @@ -9,7 +9,6 @@ M:osu.Framework.Bindables.IBindableList`1.GetBoundCopy();Fails on iOS. Use manua T:Microsoft.EntityFrameworkCore.Internal.EnumerableExtensions;Don't use internal extension methods. T:Microsoft.EntityFrameworkCore.Internal.TypeExtensions;Don't use internal extension methods. T:NuGet.Packaging.CollectionExtensions;Don't use internal extension methods. -M:System.Enum.HasFlag(System.Enum);Use osu.Framework.Extensions.EnumExtensions.HasFlagFast() instead. M:Realms.IRealmCollection`1.SubscribeForNotifications`1(Realms.NotificationCallbackDelegate{``0});Use osu.Game.Database.RealmObjectExtensions.QueryAsyncWithNotifications(IRealmCollection,NotificationCallbackDelegate) instead. M:System.Guid.#ctor;Probably meaning to use Guid.NewGuid() instead. If actually wanting empty, use Guid.Empty. M:Realms.CollectionExtensions.SubscribeForNotifications`1(System.Linq.IQueryable{``0},Realms.NotificationCallbackDelegate{``0});Use osu.Game.Database.RealmObjectExtensions.QueryAsyncWithNotifications(IQueryable,NotificationCallbackDelegate) instead. diff --git a/osu.Game.Rulesets.Karaoke.Tests/Graphics/Sprites/Processor/DisplayProcessorTestScene.cs b/osu.Game.Rulesets.Karaoke.Tests/Graphics/Sprites/Processor/DisplayProcessorTestScene.cs index 0e9c32558..22e9ea9d4 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Graphics/Sprites/Processor/DisplayProcessorTestScene.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Graphics/Sprites/Processor/DisplayProcessorTestScene.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq; using NUnit.Framework; -using osu.Framework.Extensions.EnumExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -92,7 +91,7 @@ public void TestDisplayProperty([Values] LyricDisplayProperty property) } }); - if (property.HasFlagFast(LyricDisplayProperty.TopText)) + if (property.HasFlag(LyricDisplayProperty.TopText)) { AssertTopTextChanged(); } @@ -103,7 +102,7 @@ public void TestDisplayProperty([Values] LyricDisplayProperty property) AssertCenterTextChanged(); - if (property.HasFlagFast(LyricDisplayProperty.BottomText)) + if (property.HasFlag(LyricDisplayProperty.BottomText)) { AssertBottomTextChanged(); } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Components/Sprites/DrawableLayoutPreview.cs b/osu.Game.Rulesets.Karaoke/Edit/Components/Sprites/DrawableLayoutPreview.cs index 96e7d661a..74662970c 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Components/Sprites/DrawableLayoutPreview.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Components/Sprites/DrawableLayoutPreview.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Extensions.EnumExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -111,10 +110,10 @@ private void updateLayout() float verticalMargin = Layout.VerticalMargin * scale + padding; previewLyric.Margin = new MarginPadding { - Left = Layout.Alignment.HasFlagFast(Anchor.x0) ? horizontalMargin : 0, - Right = Layout.Alignment.HasFlagFast(Anchor.x2) ? horizontalMargin : 0, - Top = Layout.Alignment.HasFlagFast(Anchor.y0) ? verticalMargin : 0, - Bottom = Layout.Alignment.HasFlagFast(Anchor.y2) ? verticalMargin : 0, + Left = Layout.Alignment.HasFlag(Anchor.x0) ? horizontalMargin : 0, + Right = Layout.Alignment.HasFlag(Anchor.x2) ? horizontalMargin : 0, + Top = Layout.Alignment.HasFlag(Anchor.y0) ? verticalMargin : 0, + Bottom = Layout.Alignment.HasFlag(Anchor.y2) ? verticalMargin : 0, }; } } diff --git a/osu.Game.Rulesets.Karaoke/Graphics/Sprites/DisplayLyricProcessor.cs b/osu.Game.Rulesets.Karaoke/Graphics/Sprites/DisplayLyricProcessor.cs index c779f0433..a4402b9aa 100644 --- a/osu.Game.Rulesets.Karaoke/Graphics/Sprites/DisplayLyricProcessor.cs +++ b/osu.Game.Rulesets.Karaoke/Graphics/Sprites/DisplayLyricProcessor.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using osu.Framework.Extensions.EnumExtensions; using osu.Framework.Graphics.Sprites; using osu.Game.Rulesets.Karaoke.Graphics.Sprites.Processor; using osu.Game.Rulesets.Karaoke.Objects; @@ -90,13 +89,13 @@ public void UpdateAll() processor.UpdateAll(); // should trigger top text update even not display. - if (!displayProperty.HasFlagFast(LyricDisplayProperty.TopText)) + if (!displayProperty.HasFlag(LyricDisplayProperty.TopText)) { TopTextChanged?.Invoke(Array.Empty()); } // should trigger bottom text update even not display. - if (!displayProperty.HasFlagFast(LyricDisplayProperty.BottomText)) + if (!displayProperty.HasFlag(LyricDisplayProperty.BottomText)) { BottomTextChanged?.Invoke(Array.Empty()); } diff --git a/osu.Game.Rulesets.Karaoke/Graphics/Sprites/Processor/BaseDisplayProcessor.cs b/osu.Game.Rulesets.Karaoke/Graphics/Sprites/Processor/BaseDisplayProcessor.cs index 264f219db..bf7559d09 100644 --- a/osu.Game.Rulesets.Karaoke/Graphics/Sprites/Processor/BaseDisplayProcessor.cs +++ b/osu.Game.Rulesets.Karaoke/Graphics/Sprites/Processor/BaseDisplayProcessor.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq; using osu.Framework.Bindables; -using osu.Framework.Extensions.EnumExtensions; using osu.Framework.Graphics.Sprites; using osu.Game.Rulesets.Karaoke.Objects; @@ -44,7 +43,7 @@ public void UpdateAll() protected void UpdateTopText() { - if (!displayProperty.HasFlagFast(LyricDisplayProperty.TopText)) + if (!displayProperty.HasFlag(LyricDisplayProperty.TopText)) return; TopTextChanged?.Invoke(CalculateTopTexts(lyric).ToArray()); @@ -57,7 +56,7 @@ protected void UpdateCenterText() protected void UpdateBottomText() { - if (!displayProperty.HasFlagFast(LyricDisplayProperty.BottomText)) + if (!displayProperty.HasFlag(LyricDisplayProperty.BottomText)) return; BottomTextChanged?.Invoke(CalculateBottomTexts(lyric).ToArray()); diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/LyricComposer.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/LyricComposer.cs index 3dd94847d..f019ac584 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/LyricComposer.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/LyricComposer.cs @@ -6,7 +6,6 @@ using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Framework.Extensions.EnumExtensions; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -163,7 +162,7 @@ private void load(KaraokeRulesetLyricEditorConfigManager lyricEditorConfigManage protected override bool OnInvalidate(Invalidation invalidation, InvalidationSource source) { - if (invalidation.HasFlagFast(Invalidation.DrawSize) && source == InvalidationSource.Parent) + if (invalidation.HasFlag(Invalidation.DrawSize) && source == InvalidationSource.Parent) calculatePanelPosition(); return base.OnInvalidate(invalidation, source); diff --git a/osu.Game.Rulesets.Karaoke/Skinning/Elements/LyricLayout.cs b/osu.Game.Rulesets.Karaoke/Skinning/Elements/LyricLayout.cs index 2061a0d2d..99bdc4b75 100644 --- a/osu.Game.Rulesets.Karaoke/Skinning/Elements/LyricLayout.cs +++ b/osu.Game.Rulesets.Karaoke/Skinning/Elements/LyricLayout.cs @@ -1,7 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Extensions.EnumExtensions; using osu.Framework.Graphics; using osu.Game.Rulesets.Karaoke.Objects.Drawables; @@ -43,10 +42,10 @@ public void ApplyTo(Drawable d) drawableLyric.Origin = Alignment; drawableLyric.Margin = new MarginPadding { - Left = Alignment.HasFlagFast(Anchor.x0) ? HorizontalMargin : 0, - Right = Alignment.HasFlagFast(Anchor.x2) ? HorizontalMargin : 0, - Top = Alignment.HasFlagFast(Anchor.y0) ? VerticalMargin : 0, - Bottom = Alignment.HasFlagFast(Anchor.y2) ? VerticalMargin : 0, + Left = Alignment.HasFlag(Anchor.x0) ? HorizontalMargin : 0, + Right = Alignment.HasFlag(Anchor.x2) ? HorizontalMargin : 0, + Top = Alignment.HasFlag(Anchor.y0) ? VerticalMargin : 0, + Bottom = Alignment.HasFlag(Anchor.y2) ? VerticalMargin : 0, }; } } diff --git a/osu.Game.Rulesets.Karaoke/UI/HUD/SettingButtonsDisplay.cs b/osu.Game.Rulesets.Karaoke/UI/HUD/SettingButtonsDisplay.cs index 6264a85c9..111610dcc 100644 --- a/osu.Game.Rulesets.Karaoke/UI/HUD/SettingButtonsDisplay.cs +++ b/osu.Game.Rulesets.Karaoke/UI/HUD/SettingButtonsDisplay.cs @@ -3,7 +3,6 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Framework.Extensions.EnumExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Layout; @@ -58,7 +57,7 @@ protected override bool OnInvalidate(Invalidation invalidation, InvalidationSour // trying to change relative position in here. if ((invalidation & Invalidation.MiscGeometry) != 0) { - var overlayDirection = Anchor.HasFlagFast(Anchor.x0) ? OverlayDirection.Left : OverlayDirection.Right; + var overlayDirection = Anchor.HasFlag(Anchor.x0) ? OverlayDirection.Left : OverlayDirection.Right; settingOverlayContainer?.ChangeOverlayDirection(overlayDirection); }