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/compress/deflate.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/compress/deflate.zig')
| -rw-r--r-- | lib/std/compress/deflate.zig | 14 |
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"); |
