From 9fd2b72c77f4e9fb508868f1bb40b29250cb98a6 Mon Sep 17 00:00:00 2001 From: anthony-zy Date: Fri, 17 Oct 2025 10:28:17 +0800 Subject: [PATCH] fix by some comments --- snappy.cc | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/snappy.cc b/snappy.cc index 9a64563..fb93e0f 100644 --- a/snappy.cc +++ b/snappy.cc @@ -1261,22 +1261,22 @@ void MemCopy64(char* dst, const void* src, size_t size) { // RVV acceleration available on RISC-V when compiled with -march=rv64gcv #elif defined(__riscv) && SNAPPY_HAVE_RVV // Cast pointers to the type we will operate on. - unsigned char* dst_ptr = (unsigned char*)dst; - const unsigned char* src_ptr = (const unsigned char*)src; + unsigned char* dst_ptr = reinterpret_cast(dst); + const unsigned char* src_ptr = reinterpret_cast(src); size_t remaining_bytes = size; - //Loop as long as there are bytes remaining to be copied. + // Loop as long as there are bytes remaining to be copied. while (remaining_bytes > 0) { - //Set vector configuration: e8 (8-bit elements), m2 (LMUL=2). - //Use e8m2 configuration to maximize throughput. - size_t vl = VSETVL_E8M2(remaining_bytes); - //Load data from the current source pointer. - vuint8m2_t vec = VLE8_V_U8M2(src_ptr, vl); - //Store data to the current destination pointer. - VSE8_V_U8M2(dst_ptr, vec, vl); - //Update pointers and the remaining count. - src_ptr += vl; - dst_ptr += vl; - remaining_bytes -= vl; + // Set vector configuration: e8 (8-bit elements), m2 (LMUL=2). + // Use e8m2 configuration to maximize throughput. + size_t vl = VSETVL_E8M2(remaining_bytes); + // Load data from the current source pointer. + vuint8m2_t vec = VLE8_V_U8M2(src_ptr, vl); + // Store data to the current destination pointer. + VSE8_V_U8M2(dst_ptr, vec, vl); + // Update pointers and the remaining count. + src_ptr += vl; + dst_ptr += vl; + remaining_bytes -= vl; } #else @@ -1284,8 +1284,8 @@ void MemCopy64(char* dst, const void* src, size_t size) { //Profiling shows that nearly all copies are short. if (SNAPPY_PREDICT_FALSE(size > kShortMemCopy)) { std::memmove(dst + kShortMemCopy, - static_cast(src) + kShortMemCopy, - 64 - kShortMemCopy);} + static_cast(src) + kShortMemCopy, + 64 - kShortMemCopy); #endif }