Skip to content

Commit

Permalink
use AsSpan() instead of Substring()
Browse files Browse the repository at this point in the history
  • Loading branch information
smdn committed Feb 3, 2022
1 parent b484cc8 commit 9d07cba
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Smdn.Fundamental.Uuid/Smdn/Uuid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -675,10 +675,15 @@ public Uuid(string uuid)

if (
fields[3].Length != 4 ||
#if NETSTANDARD2_1_OR_GREATER
!byte.TryParse(fields[3].AsSpan(0, 2), NumberStyles.HexNumber, null, out clock_seq_hi_and_reserved) ||
!byte.TryParse(fields[3].AsSpan(2, 2), NumberStyles.HexNumber, null, out clock_seq_low)
#else
#pragma warning disable IDE0057
!byte.TryParse(fields[3].Substring(0, 2), NumberStyles.HexNumber, null, out clock_seq_hi_and_reserved) ||
!byte.TryParse(fields[3].Substring(2, 2), NumberStyles.HexNumber, null, out clock_seq_low)
#pragma warning restore IDE0057
#endif
) {
throw new FormatException($"invalid UUID (clock_seq_hi_and_reserved or clock_seq_low): {uuid}");
}
Expand Down

0 comments on commit 9d07cba

Please sign in to comment.