@@ -1144,33 +1144,32 @@ void CompactObj::GetString(char* dest) const {
11441144 }
11451145
11461146 if (mask_bits_.encoding ) {
1147+ StrEncoding str_encoding = GetStrEncoding ();
1148+ string_view decode_blob;
1149+
11471150 if (taglen_ == ROBJ_TAG) {
11481151 CHECK_EQ (OBJ_STRING, u_.r_obj .type ());
11491152 DCHECK_EQ (OBJ_ENCODING_RAW, u_.r_obj .encoding ());
1150- string_view blob{(const char *)u_.r_obj .inner_obj (), u_.r_obj .Size ()};
1151- GetStrEncoding ().Decode (blob, dest);
1152- return ;
1153+ decode_blob = {(const char *)u_.r_obj .inner_obj (), u_.r_obj .Size ()};
11531154 } else {
11541155 CHECK_EQ (SMALL_TAG, taglen_);
11551156 auto & ss = u_.small_str ;
11561157
1157- size_t decoded_len = GetStrEncoding ().DecodedSize (ss.size (), ss.first_byte ());
1158-
1159- if (mask_bits_.encoding == HUFFMAN_ENC) {
1158+ char * copy_dest;
1159+ if (str_encoding.enc_ == HUFFMAN_ENC) {
11601160 tl.tmp_buf .resize (ss.size ());
1161- auto * base = reinterpret_cast <char *>(tl.tmp_buf .data ());
1162- ss.Get (base);
1163-
1164- const auto & decoder = tl.GetHuffmanDecoder (huffman_domain_);
1165- CHECK (decoder.Decode ({base + 1 , ss.size () - 1 }, decoded_len, dest)); // skip first char
1166- return ;
1161+ copy_dest = reinterpret_cast <char *>(tl.tmp_buf .data ());
1162+ } else {
1163+ // Write to rightmost location of dest buffer to leave some bytes for inline unpacking
1164+ size_t decoded_len = str_encoding.DecodedSize (ss.size (), ss.first_byte ());
1165+ copy_dest = dest + (decoded_len - ss.size ());
11671166 }
11681167
1169- // we left some space on the left to allow inplace ascii unpacking.
1170- char * offset_dest = dest + (decoded_len - u_.small_str .size ());
1171- ss.Get (offset_dest);
1172- detail::ascii_unpack_simd (reinterpret_cast <uint8_t *>(offset_dest), decoded_len, dest);
1168+ ss.Get (copy_dest);
1169+ decode_blob = {copy_dest, ss.size ()};
11731170 }
1171+
1172+ str_encoding.Decode (decode_blob, dest);
11741173 return ;
11751174 }
11761175
0 commit comments