未验证 提交 23d16da1 编写于 作者: S Stephen Toub 提交者: GitHub

Change a byte[] in KnownColorTable to be ReadOnlySpan<byte> (#51719)

上级 1e28943d
......@@ -238,7 +238,7 @@ internal static class KnownColorTable
};
// All known color kinds (in order of definition in the KnownColor enum).
public static readonly byte[] s_colorKindTable = new byte[]
public static ReadOnlySpan<byte> ColorKindTable => new byte[]
{
// "not a known color"
KnownColorKindUnknown,
......@@ -466,11 +466,11 @@ internal static class KnownColorTable
internal static Color ArgbToKnownColor(uint argb)
{
Debug.Assert((argb & Color.ARGBAlphaMask) == Color.ARGBAlphaMask);
Debug.Assert(s_colorValueTable.Length == s_colorKindTable.Length);
Debug.Assert(s_colorValueTable.Length == ColorKindTable.Length);
for (int index = 1; index < s_colorValueTable.Length; ++index)
{
if (s_colorKindTable[index] == KnownColorKindWeb && s_colorValueTable[index] == argb)
if (ColorKindTable[index] == KnownColorKindWeb && s_colorValueTable[index] == argb)
{
return Color.FromKnownColor((KnownColor)index);
}
......@@ -484,7 +484,7 @@ public static uint KnownColorToArgb(KnownColor color)
{
Debug.Assert(color > 0 && color <= KnownColor.RebeccaPurple);
return s_colorKindTable[(int)color] == KnownColorKindSystem
return ColorKindTable[(int)color] == KnownColorKindSystem
? GetSystemColorArgb(color)
: s_colorValueTable[(int)color];
}
......
......@@ -374,7 +374,7 @@ private Color(long value, short state, string? name, KnownColor knownColor)
public bool IsSystemColor => IsKnownColor && IsKnownColorSystem((KnownColor)knownColor);
internal static bool IsKnownColorSystem(KnownColor knownColor)
=> KnownColorTable.s_colorKindTable[(int)knownColor] == KnownColorTable.KnownColorKindSystem;
=> KnownColorTable.ColorKindTable[(int)knownColor] == KnownColorTable.KnownColorKindSystem;
// Used for the [DebuggerDisplay]. Inlining in the attribute is possible, but
// against best practices as the current project language parses the string with
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册