Skip to content

Commit

Permalink
HasFlagFast() is imported in the 3 years ago:
Browse files Browse the repository at this point in the history
#967

And it's removed in this update due to HasFlag() is faster than HasFlagFast():
#2250
  • Loading branch information
andy840119 committed Jul 20, 2024
1 parent eeb4eed commit d9f052e
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 24 deletions.
1 change: 0 additions & 1 deletion CodeAnalysis/BannedSymbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>() instead.
M:Realms.IRealmCollection`1.SubscribeForNotifications`1(Realms.NotificationCallbackDelegate{``0});Use osu.Game.Database.RealmObjectExtensions.QueryAsyncWithNotifications(IRealmCollection<T>,NotificationCallbackDelegate<T>) 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<T>,NotificationCallbackDelegate<T>) instead.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -92,7 +91,7 @@ public void TestDisplayProperty([Values] LyricDisplayProperty property)
}
});

if (property.HasFlagFast(LyricDisplayProperty.TopText))
if (property.HasFlag(LyricDisplayProperty.TopText))
{
AssertTopTextChanged();
}
Expand All @@ -103,7 +102,7 @@ public void TestDisplayProperty([Values] LyricDisplayProperty property)

AssertCenterTextChanged();

if (property.HasFlagFast(LyricDisplayProperty.BottomText))
if (property.HasFlag(LyricDisplayProperty.BottomText))
{
AssertBottomTextChanged();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<PositionText>());
}

// should trigger bottom text update even not display.
if (!displayProperty.HasFlagFast(LyricDisplayProperty.BottomText))
if (!displayProperty.HasFlag(LyricDisplayProperty.BottomText))
{
BottomTextChanged?.Invoke(Array.Empty<PositionText>());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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());
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 4 additions & 5 deletions osu.Game.Rulesets.Karaoke/Skinning/Elements/LyricLayout.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) andy840119 <[email protected]>. 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;

Expand Down Expand Up @@ -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,
};
}
}
3 changes: 1 addition & 2 deletions osu.Game.Rulesets.Karaoke/UI/HUD/SettingButtonsDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit d9f052e

Please sign in to comment.