diff --git a/src/libraries/System.Linq/src/System/Linq/Range.SpeedOpt.cs b/src/libraries/System.Linq/src/System/Linq/Range.SpeedOpt.cs index c058142839c673..176d0edc1a076c 100644 --- a/src/libraries/System.Linq/src/System/Linq/Range.SpeedOpt.cs +++ b/src/libraries/System.Linq/src/System/Linq/Range.SpeedOpt.cs @@ -45,7 +45,7 @@ private static void Fill(Span destination, int value) Vector.Count <= 8 && destination.Length >= Vector.Count) { - Vector init = new Vector((ReadOnlySpan)new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }); + Vector init = new Vector((ReadOnlySpan)[0, 1, 2, 3, 4, 5, 6, 7]); Vector current = new Vector(value) + init; Vector increment = new Vector(Vector.Count); diff --git a/src/libraries/System.Net.Primitives/src/System/Net/IPAddress.cs b/src/libraries/System.Net.Primitives/src/System/Net/IPAddress.cs index a4c0dc55200196..bdd381fc04901c 100644 --- a/src/libraries/System.Net.Primitives/src/System/Net/IPAddress.cs +++ b/src/libraries/System.Net.Primitives/src/System/Net/IPAddress.cs @@ -21,18 +21,18 @@ namespace System.Net /// public class IPAddress : ISpanFormattable, ISpanParsable, IUtf8SpanFormattable { - public static readonly IPAddress Any = new ReadOnlyIPAddress(new byte[] { 0, 0, 0, 0 }); - public static readonly IPAddress Loopback = new ReadOnlyIPAddress(new byte[] { 127, 0, 0, 1 }); - public static readonly IPAddress Broadcast = new ReadOnlyIPAddress(new byte[] { 255, 255, 255, 255 }); + public static readonly IPAddress Any = new ReadOnlyIPAddress([0, 0, 0, 0]); + public static readonly IPAddress Loopback = new ReadOnlyIPAddress([127, 0, 0, 1]); + public static readonly IPAddress Broadcast = new ReadOnlyIPAddress([255, 255, 255, 255]); public static readonly IPAddress None = Broadcast; internal const uint LoopbackMaskHostOrder = 0xFF000000; - public static readonly IPAddress IPv6Any = new IPAddress((ReadOnlySpan)new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0); - public static readonly IPAddress IPv6Loopback = new IPAddress((ReadOnlySpan)new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, 0); + public static readonly IPAddress IPv6Any = new IPAddress((ReadOnlySpan)[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 0); + public static readonly IPAddress IPv6Loopback = new IPAddress((ReadOnlySpan)[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], 0); public static readonly IPAddress IPv6None = IPv6Any; - private static readonly IPAddress s_loopbackMappedToIPv6 = new IPAddress((ReadOnlySpan)new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 127, 0, 0, 1 }, 0); + private static readonly IPAddress s_loopbackMappedToIPv6 = new IPAddress((ReadOnlySpan)[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 127, 0, 0, 1], 0); /// /// For IPv4 addresses, this field stores the Address. diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/UTF32Encoding.cs b/src/libraries/System.Private.CoreLib/src/System/Text/UTF32Encoding.cs index 9afbf6736ff08c..83d4e2ee6daa21 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/UTF32Encoding.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/UTF32Encoding.cs @@ -1122,8 +1122,8 @@ public override byte[] GetPreamble() public override ReadOnlySpan Preamble => GetType() != typeof(UTF32Encoding) ? new ReadOnlySpan(GetPreamble()) : // in case a derived UTF32Encoding overrode GetPreamble !_emitUTF32ByteOrderMark ? default : - _bigEndian ? (ReadOnlySpan)new byte[4] { 0x00, 0x00, 0xFE, 0xFF } : // uses C# compiler's optimization for static byte[] data - (ReadOnlySpan)new byte[4] { 0xFF, 0xFE, 0x00, 0x00 }; + _bigEndian ? [0x00, 0x00, 0xFE, 0xFF] : + [0xFF, 0xFE, 0x00, 0x00]; public override bool Equals([NotNullWhen(true)] object? value) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/UnicodeEncoding.cs b/src/libraries/System.Private.CoreLib/src/System/Text/UnicodeEncoding.cs index 9cf17f76706d79..6bee6e9d6aae4c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/UnicodeEncoding.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/UnicodeEncoding.cs @@ -1746,8 +1746,8 @@ public override byte[] GetPreamble() public override ReadOnlySpan Preamble => GetType() != typeof(UnicodeEncoding) ? new ReadOnlySpan(GetPreamble()) : // in case a derived UnicodeEncoding overrode GetPreamble !byteOrderMark ? default : - bigEndian ? (ReadOnlySpan)new byte[2] { 0xfe, 0xff } : // uses C# compiler's optimization for static byte[] data - (ReadOnlySpan)new byte[2] { 0xff, 0xfe }; + bigEndian ? [0xfe, 0xff] : + [0xff, 0xfe]; public override int GetMaxByteCount(int charCount) {