DoxigAlpha

update

Function parameters

Parameters

#
self:*Self
bytes:[]const u8

Functions in this namespace

Functions

#

Source

Implementation

#
pub fn update(self: *Self, bytes: []const u8) void {
    var i: usize = 0;
    if (@bitSizeOf(I) <= 8) {
        while (i < bytes.len) : (i += 1) {
            self.crc = tableEntry(self.crc ^ bytes[i]);
        }
    } else if (algorithm.reflect_input) {
        while (i < bytes.len) : (i += 1) {
            const table_index = self.crc ^ bytes[i];
            self.crc = tableEntry(table_index) ^ (self.crc >> 8);
        }
    } else {
        while (i < bytes.len) : (i += 1) {
            const table_index = (self.crc >> (@bitSizeOf(I) - 8)) ^ bytes[i];
            self.crc = tableEntry(table_index) ^ (self.crc << 8);
        }
    }
}