aboutsummaryrefslogtreecommitdiff
path: root/lib/std/compress/deflate.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-04-29 00:19:55 -0700
committerGitHub <noreply@github.com>2023-04-29 00:19:55 -0700
commitd65b42e07caa00dfe2f2fbf221c593ce57882784 (patch)
tree7926cbea1499e0affe930bf6d7455dc24adf014e /lib/std/compress/deflate.zig
parentfd6200eda6d4fe19c34a59430a88a9ce38d6d7a4 (diff)
parentfa200ca0cad2705bad40eb723dedf4e3bf11f2ff (diff)
downloadzig-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/compress/deflate.zig')
-rw-r--r--lib/std/compress/deflate.zig14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/std/compress/deflate.zig b/lib/std/compress/deflate.zig
index 7b079a6039..2fe5969067 100644
--- a/lib/std/compress/deflate.zig
+++ b/lib/std/compress/deflate.zig
@@ -12,6 +12,20 @@ pub const Decompressor = inflate.Decompressor;
pub const compressor = deflate.compressor;
pub const decompressor = inflate.decompressor;
+/// Copies elements from a source `src` slice into a destination `dst` slice.
+/// The copy never returns an error but might not be complete if the destination is too small.
+/// Returns the number of elements copied, which will be the minimum of `src.len` and `dst.len`.
+/// TODO: remove this smelly function
+pub fn copy(dst: []u8, src: []const u8) usize {
+ if (dst.len <= src.len) {
+ @memcpy(dst, src[0..dst.len]);
+ return dst.len;
+ } else {
+ @memcpy(dst[0..src.len], src);
+ return src.len;
+ }
+}
+
test {
_ = @import("deflate/token.zig");
_ = @import("deflate/bits_utils.zig");