aboutsummaryrefslogtreecommitdiffstats
path: root/src/crc16.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/crc16.zig')
-rw-r--r--src/crc16.zig4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/crc16.zig b/src/crc16.zig
index 3ea5a15..1257ea2 100644
--- a/src/crc16.zig
+++ b/src/crc16.zig
@@ -7,7 +7,7 @@ const crc16tab: [256]u16 = tab: {
7 const poly: u32 = 0x1021; 7 const poly: u32 = 0x1021;
8 var table: [256]u16 = undefined; 8 var table: [256]u16 = undefined;
9 9
10 for (table) |*crc, i| { 10 for (&table, 0..) |*crc, i| {
11 crc.* = @as(u16, i) << 8; 11 crc.* = @as(u16, i) << 8;
12 var j = 0; 12 var j = 0;
13 while (j < 8) : (j += 1) { 13 while (j < 8) : (j += 1) {
@@ -25,7 +25,7 @@ const crc16tab: [256]u16 = tab: {
25pub fn update(crc: u16, with_data: []const u8) u16 { 25pub fn update(crc: u16, with_data: []const u8) u16 {
26 var new_crc = crc; 26 var new_crc = crc;
27 for (with_data) |b| { 27 for (with_data) |b| {
28 new_crc = (new_crc << 8) ^ crc16tab[@truncate(u8, new_crc >> 8) ^ b]; 28 new_crc = (new_crc << 8) ^ crc16tab[@as(u8, @truncate(new_crc >> 8)) ^ b];
29 } 29 }
30 return new_crc; 30 return new_crc;
31} 31}