From 054ac58ae16898a8ed63b92572f4660eaa744d0a Mon Sep 17 00:00:00 2001 From: "zhuna.1024" Date: Mon, 29 Aug 2022 21:28:56 +0800 Subject: [PATCH] replace memset in GetHashTable to pure SIMD --- snappy.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/snappy.cc b/snappy.cc index 6502cfd..67c2cff 100644 --- a/snappy.cc +++ b/snappy.cc @@ -703,8 +703,17 @@ WorkingMemory::~WorkingMemory() { uint16_t* WorkingMemory::GetHashTable(size_t fragment_size, int* table_size) const { const size_t htsize = CalculateTableSize(fragment_size); - memset(table_, 0, htsize * sizeof(*table_)); *table_size = htsize; + #if SNAPPY_HAVE_VECTOR_BYTE_SHUFFLE + assert(table_size % 16 == 0); + table_[0] = 0; + V128 pattern = V128_DupChar(table_[0]); + for(uint64_t i = 0; i < htsize * sizeof(*table_) / 16; i++ ) { + V128_StoreU(reinterpret_cast(reinterpret_cast(table_) + 16 * i), pattern); + } + #else + memset(table_, 0, htsize * sizeof(*table_)); + #endif return table_; } } // end namespace internal