Skip to content

Commit 0f43203

Browse files
committed
refactor: 更改参数类型
1 parent 1f8ad3f commit 0f43203

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/extensions/BootstrapBlazor.Socket/Utility/ModbusCrc16.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@ public static ReadOnlySpan<byte> Append(ReadOnlySpan<byte> data)
9595
/// </summary>
9696
/// <param name="dataWithCrc">包含 CRC 校验码的数据</param>
9797
/// <returns>验证结果</returns>
98-
public static bool ValidateChecksum(byte[] dataWithCrc)
98+
public static bool Validate(ReadOnlySpan<byte> dataWithCrc)
9999
{
100100
if (dataWithCrc.Length < 2)
101101
{
102102
return false;
103103
}
104104

105105
ushort receivedCrc = (ushort)(dataWithCrc[^1] << 8 | dataWithCrc[^2]);
106-
ushort calculatedCrc = Compute(dataWithCrc.AsSpan()[..^2]);
106+
ushort calculatedCrc = Compute(dataWithCrc[..^2]);
107107
return receivedCrc == calculatedCrc;
108108
}
109109
}

0 commit comments

Comments
 (0)