From 44caf79086541716b0fce0fe7047cb76e4165b04 Mon Sep 17 00:00:00 2001 From: Marcin Kowalczyk Date: Thu, 9 Jun 2022 14:28:22 +0000 Subject: Move the comment about non-overlap requirement from the implementation to the contract of `MemCopy64()`, and clarify that it applies to `size`, not to 64. PiperOrigin-RevId: 453920284 --- snappy.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snappy.cc b/snappy.cc index 21d0c01..ff3a9ed 100644 --- a/snappy.cc +++ b/snappy.cc @@ -985,7 +985,8 @@ inline bool Copy64BytesWithPatternExtension(ptrdiff_t dst, size_t offset) { // Copies between size bytes and 64 bytes from src to dest. size cannot exceed // 64. More than size bytes, but never exceeding 64, might be copied if doing -// so gives better performance. +// so gives better performance. [src, src + size) must not overlap with +// [dst, dst + size), but [src, src + 64) may overlap with [dst, dst + 64). void MemCopy64(char* dst, const void* src, size_t size) { // Always copy this many bytes, test if we need to copy more. constexpr int kShortMemCopy = 32; @@ -994,7 +995,6 @@ void MemCopy64(char* dst, const void* src, size_t size) { constexpr int kLongMemCopy = 64; assert(size <= kLongMemCopy); - // [src, src + size) must not overlap with [dst, dst + size) assert(std::less_equal()(static_cast(src) + size, dst) || std::less_equal()(dst + size, src)); -- cgit v1.2.1