From 82b0cd844f833f3e0488356b38410ef65417a278 Mon Sep 17 00:00:00 2001 From: helloguo Date: Mon, 27 Jul 2020 22:08:52 -0700 Subject: [PATCH 1/2] Optimize ZSTD_wildcopy --- lib/common/zstd_internal.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/common/zstd_internal.h b/lib/common/zstd_internal.h index ee3cb51bf..557ae60d4 100644 --- a/lib/common/zstd_internal.h +++ b/lib/common/zstd_internal.h @@ -290,8 +290,10 @@ void ZSTD_wildcopy(void* dst, const void* src, ptrdiff_t length, ZSTD_overlap_e } while (op < oend); #else - COPY16(op, ip); - if (op >= oend) return; + memcpy(op, ip, 16); + if (16 >= length) return; + op += 16; + ip += 16; do { COPY16(op, ip); COPY16(op, ip); From acb3dd9a68d4a18ffb6c936345c6d7f4369678fd Mon Sep 17 00:00:00 2001 From: helloguo Date: Tue, 28 Jul 2020 11:58:46 -0700 Subject: [PATCH 2/2] Use ZSTD_copy16 instead of memcpy --- lib/common/zstd_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/common/zstd_internal.h b/lib/common/zstd_internal.h index 557ae60d4..9fd2a6acc 100644 --- a/lib/common/zstd_internal.h +++ b/lib/common/zstd_internal.h @@ -290,7 +290,7 @@ void ZSTD_wildcopy(void* dst, const void* src, ptrdiff_t length, ZSTD_overlap_e } while (op < oend); #else - memcpy(op, ip, 16); + ZSTD_copy16(op, ip); if (16 >= length) return; op += 16; ip += 16;