diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-04-29 00:19:55 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-29 00:19:55 -0700 |
| commit | d65b42e07caa00dfe2f2fbf221c593ce57882784 (patch) | |
| tree | 7926cbea1499e0affe930bf6d7455dc24adf014e /lib/std/rand/ChaCha.zig | |
| parent | fd6200eda6d4fe19c34a59430a88a9ce38d6d7a4 (diff) | |
| parent | fa200ca0cad2705bad40eb723dedf4e3bf11f2ff (diff) | |
| download | zig-d65b42e07caa00dfe2f2fbf221c593ce57882784.tar.gz zig-d65b42e07caa00dfe2f2fbf221c593ce57882784.zip | |
Merge pull request #15481 from ziglang/use-mem-intrinsics
actually use the new memory intrinsics
Diffstat (limited to 'lib/std/rand/ChaCha.zig')
| -rw-r--r-- | lib/std/rand/ChaCha.zig | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/std/rand/ChaCha.zig b/lib/std/rand/ChaCha.zig index 0992aeb97e..3878fb25c8 100644 --- a/lib/std/rand/ChaCha.zig +++ b/lib/std/rand/ChaCha.zig @@ -40,7 +40,8 @@ pub fn addEntropy(self: *Self, bytes: []const u8) void { } if (i < bytes.len) { var k = [_]u8{0} ** Cipher.key_length; - mem.copy(u8, k[0..], bytes[i..]); + const src = bytes[i..]; + @memcpy(k[0..src.len], src); Cipher.xor( self.state[0..Cipher.key_length], self.state[0..Cipher.key_length], @@ -72,8 +73,8 @@ pub fn fill(self: *Self, buf_: []u8) void { if (avail > 0) { // Bytes from the current block const n = @min(avail, buf.len); - mem.copy(u8, buf[0..n], bytes[self.offset..][0..n]); - mem.set(u8, bytes[self.offset..][0..n], 0); + @memcpy(buf[0..n], bytes[self.offset..][0..n]); + @memset(bytes[self.offset..][0..n], 0); buf = buf[n..]; self.offset += n; } @@ -83,15 +84,15 @@ pub fn fill(self: *Self, buf_: []u8) void { // Full blocks while (buf.len >= bytes.len) { - mem.copy(u8, buf[0..bytes.len], bytes); + @memcpy(buf[0..bytes.len], bytes); buf = buf[bytes.len..]; self.refill(); } // Remaining bytes if (buf.len > 0) { - mem.copy(u8, buf, bytes[0..buf.len]); - mem.set(u8, bytes[0..buf.len], 0); + @memcpy(buf, bytes[0..buf.len]); + @memset(bytes[0..buf.len], 0); self.offset = buf.len; } } |
