Skip to content

Commit 9d07cba

Browse files
committed
use AsSpan() instead of Substring()
1 parent b484cc8 commit 9d07cba

File tree

1 file changed

+5
-0
lines changed
  • src/Smdn.Fundamental.Uuid/Smdn

1 file changed

+5
-0
lines changed

src/Smdn.Fundamental.Uuid/Smdn/Uuid.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,10 +675,15 @@ public Uuid(string uuid)
675675

676676
if (
677677
fields[3].Length != 4 ||
678+
#if NETSTANDARD2_1_OR_GREATER
679+
!byte.TryParse(fields[3].AsSpan(0, 2), NumberStyles.HexNumber, null, out clock_seq_hi_and_reserved) ||
680+
!byte.TryParse(fields[3].AsSpan(2, 2), NumberStyles.HexNumber, null, out clock_seq_low)
681+
#else
678682
#pragma warning disable IDE0057
679683
!byte.TryParse(fields[3].Substring(0, 2), NumberStyles.HexNumber, null, out clock_seq_hi_and_reserved) ||
680684
!byte.TryParse(fields[3].Substring(2, 2), NumberStyles.HexNumber, null, out clock_seq_low)
681685
#pragma warning restore IDE0057
686+
#endif
682687
) {
683688
throw new FormatException($"invalid UUID (clock_seq_hi_and_reserved or clock_seq_low): {uuid}");
684689
}

0 commit comments

Comments
 (0)