aboutsummaryrefslogtreecommitdiff
path: root/lib/std/rand
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std/rand')
-rw-r--r--lib/std/rand/ChaCha.zig13
-rw-r--r--lib/std/rand/Isaac64.zig4
2 files changed, 9 insertions, 8 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;
}
}
diff --git a/lib/std/rand/Isaac64.zig b/lib/std/rand/Isaac64.zig
index 42242008fc..8c6205e1cd 100644
--- a/lib/std/rand/Isaac64.zig
+++ b/lib/std/rand/Isaac64.zig
@@ -87,7 +87,7 @@ fn next(self: *Isaac64) u64 {
fn seed(self: *Isaac64, init_s: u64, comptime rounds: usize) void {
// We ignore the multi-pass requirement since we don't currently expose full access to
// seeding the self.m array completely.
- mem.set(u64, self.m[0..], 0);
+ @memset(self.m[0..], 0);
self.m[0] = init_s;
// prescrambled golden ratio constants
@@ -143,7 +143,7 @@ fn seed(self: *Isaac64, init_s: u64, comptime rounds: usize) void {
}
}
- mem.set(u64, self.r[0..], 0);
+ @memset(self.r[0..], 0);
self.a = 0;
self.b = 0;
self.c = 0;