Skip to content

Commit

Permalink
Use lazy initialisation for IOExtensions.ShiftJISEncoding
Browse files Browse the repository at this point in the history
see #4150
  • Loading branch information
YoshiRulz committed Dec 30, 2024
1 parent 0ec54fe commit 2cb6d2c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/BizHawk.Common/Extensions/IOExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ namespace BizHawk.Common.IOExtensions
{
public static class IOExtensions
{
public static readonly Encoding ShiftJISEncoding = Encoding.GetEncoding("shift_jis");
private static Encoding? _shiftJIS = null;

public static Encoding ShiftJISEncoding
=> _shiftJIS ??= Encoding.GetEncoding("shift_jis");

public static Span<byte> GetBufferAsSpan(this MemoryStream ms)
=> ms.GetBuffer().AsSpan().Slice(start: 0, length: (int) ms.Length);
Expand Down

0 comments on commit 2cb6d2c

Please sign in to comment.