| ... | @@ -38,7 +38,7 @@ pub const State = struct { | ... | @@ -38,7 +38,7 @@ pub const State = struct { |
| 38 | return mem.sliceAsBytes(self.data[0..]); | 38 | return mem.sliceAsBytes(self.data[0..]); |
| 39 | } | 39 | } |
| 40 | | 40 | |
| 41 | fn _permute_unrolled(self: *Self) void { | 41 | fn permute_unrolled(self: *Self) void { |
| 42 | const state = &self.data; | 42 | const state = &self.data; |
| 43 | comptime var round = @as(u32, 24); | 43 | comptime var round = @as(u32, 24); |
| 44 | inline while (round > 0) : (round -= 1) { | 44 | inline while (round > 0) : (round -= 1) { |
| ... | @@ -66,7 +66,7 @@ pub const State = struct { | ... | @@ -66,7 +66,7 @@ pub const State = struct { |
| 66 | } | 66 | } |
| 67 | } | 67 | } |
| 68 | | 68 | |
| 69 | fn _permute_small(self: *Self) void { | 69 | fn permute_small(self: *Self) void { |
| 70 | const state = &self.data; | 70 | const state = &self.data; |
| 71 | var round = @as(u32, 24); | 71 | var round = @as(u32, 24); |
| 72 | while (round > 0) : (round -= 1) { | 72 | while (round > 0) : (round -= 1) { |
| ... | @@ -94,13 +94,7 @@ pub const State = struct { | ... | @@ -94,13 +94,7 @@ pub const State = struct { |
| 94 | } | 94 | } |
| 95 | } | 95 | } |
| 96 | | 96 | |
| 97 | pub fn permute(self: *Self) void { | 97 | pub const permute = if (std.builtin.mode == .ReleaseSmall) permute_small else permute_unrolled; |
| 98 | if (std.builtin.mode == .ReleaseSmall) { | | |
| 99 | self._permute_small(); | | |
| 100 | } else { | | |
| 101 | self._permute_unrolled(); | | |
| 102 | } | | |
| 103 | } | | |
| 104 | | 98 | |
| 105 | pub fn squeeze(self: *Self, out: []u8) void { | 99 | pub fn squeeze(self: *Self, out: []u8) void { |
| 106 | var i = @as(usize, 0); | 100 | var i = @as(usize, 0); |