diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/compproto/compressor.h | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/compproto/compressor.h')
-rw-r--r-- | library/cpp/compproto/compressor.h | 114 |
1 files changed, 57 insertions, 57 deletions
diff --git a/library/cpp/compproto/compressor.h b/library/cpp/compproto/compressor.h index 14b335e13c..0e3a27afd0 100644 --- a/library/cpp/compproto/compressor.h +++ b/library/cpp/compproto/compressor.h @@ -3,72 +3,72 @@ #include <util/system/defaults.h> namespace NCompProto { - struct TEmpty { - }; + struct TEmpty { + }; - struct TTable { - TTable() { - for (size_t i = 0; i < 64; ++i) { - CodeBase[i] = 0; - CodeMask[i] = 0; - Length[i] = 0; - PrefLength[i] = 0; - Id[i] = 0; - } + struct TTable { + TTable() { + for (size_t i = 0; i < 64; ++i) { + CodeBase[i] = 0; + CodeMask[i] = 0; + Length[i] = 0; + PrefLength[i] = 0; + Id[i] = 0; + } } - ui32 CodeBase[64]; - ui32 CodeMask[64]; - ui8 Length[64]; - ui8 PrefLength[64]; - ui8 Id[64]; - enum { - PAGE_BOUND = 4096, + ui32 CodeBase[64]; + ui32 CodeMask[64]; + ui8 Length[64]; + ui8 PrefLength[64]; + ui8 Id[64]; + enum { + PAGE_BOUND = 4096, #ifdef WITH_VALGRIND - SAFE_MODE = 1, + SAFE_MODE = 1, #else -#if defined(__has_feature) -#if __has_feature(address_sanitizer) +#if defined(__has_feature) +#if __has_feature(address_sanitizer) SAFE_MODE = 1, -#else +#else SAFE_MODE = 0, #endif -#else - SAFE_MODE = 0, -#endif -#endif - }; - ui32 inline Decompress(const ui8* codes, ui64& offset) const { - codes += (offset >> 3); - size_t pageOff = size_t(codes) % PAGE_BOUND; - size_t readOff = offset & 7; - if (pageOff > PAGE_BOUND - 8 || SAFE_MODE) { - size_t off = 8; - ui64 res = codes[0]; +#else + SAFE_MODE = 0, +#endif +#endif + }; + ui32 inline Decompress(const ui8* codes, ui64& offset) const { + codes += (offset >> 3); + size_t pageOff = size_t(codes) % PAGE_BOUND; + size_t readOff = offset & 7; + if (pageOff > PAGE_BOUND - 8 || SAFE_MODE) { + size_t off = 8; + ui64 res = codes[0]; ++codes; - ui64 indexCur = ((res + 0x0000) >> readOff) & 63; - ui64 indexAlt = ((res + 0xff00) >> readOff) & 63; - if (Id[indexCur] != Id[indexAlt]) { - res += (ui64(codes[0]) << off); - ++codes; - off += 8; - indexCur = (res >> readOff) & 63; - } - ui64 index = indexCur; - ui64 length = Length[index]; - while (off < readOff + length) { - res += (ui64(codes[0]) << off); - ++codes; - off += 8; - } - offset += length; - ui64 code = res >> readOff; - return (((ui32)(code >> PrefLength[index])) & CodeMask[index]) + CodeBase[index]; + ui64 indexCur = ((res + 0x0000) >> readOff) & 63; + ui64 indexAlt = ((res + 0xff00) >> readOff) & 63; + if (Id[indexCur] != Id[indexAlt]) { + res += (ui64(codes[0]) << off); + ++codes; + off += 8; + indexCur = (res >> readOff) & 63; + } + ui64 index = indexCur; + ui64 length = Length[index]; + while (off < readOff + length) { + res += (ui64(codes[0]) << off); + ++codes; + off += 8; + } + offset += length; + ui64 code = res >> readOff; + return (((ui32)(code >> PrefLength[index])) & CodeMask[index]) + CodeBase[index]; } - ui64 code = ((const ui64*)(codes))[0] >> readOff; - ui64 index = code & 63; - offset += Length[index]; + ui64 code = ((const ui64*)(codes))[0] >> readOff; + ui64 index = code & 63; + offset += Length[index]; return (((ui32)(code >> PrefLength[index])) & CodeMask[index]) + CodeBase[index]; } - }; + }; -} +} |