aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/bit_io/bitinput_impl.h
diff options
context:
space:
mode:
authorRuslan Kovalev <ruslan.a.kovalev@gmail.com>2022-02-10 16:46:44 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:44 +0300
commit59e19371de37995fcb36beb16cd6ec030af960bc (patch)
treefa68e36093ebff8b805462e9e6d331fe9d348214 /library/cpp/bit_io/bitinput_impl.h
parent89db6fe2fe2c32d2a832ddfeb04e8d078e301084 (diff)
downloadydb-59e19371de37995fcb36beb16cd6ec030af960bc.tar.gz
Restoring authorship annotation for Ruslan Kovalev <ruslan.a.kovalev@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/bit_io/bitinput_impl.h')
-rw-r--r--library/cpp/bit_io/bitinput_impl.h42
1 files changed, 21 insertions, 21 deletions
diff --git a/library/cpp/bit_io/bitinput_impl.h b/library/cpp/bit_io/bitinput_impl.h
index b13fbef101..d1c05f9be2 100644
--- a/library/cpp/bit_io/bitinput_impl.h
+++ b/library/cpp/bit_io/bitinput_impl.h
@@ -1,9 +1,9 @@
-#pragma once
-
+#pragma once
+
#include <util/generic/bitops.h>
#include <util/system/unaligned_mem.h>
-namespace NBitIO {
+namespace NBitIO {
class TBitInputImpl {
i64 RealStart;
i64 Start;
@@ -12,7 +12,7 @@ namespace NBitIO {
const ui32 FakeStart;
char Fake[16];
const i64 FStart;
-
+
public:
TBitInputImpl(const char* start, const char* end)
: RealStart((i64)start)
@@ -25,11 +25,11 @@ namespace NBitIO {
memcpy(Fake, (const char*)(RealStart + (FakeStart >> 3)), (Length - FakeStart) >> 3);
Start = FakeStart ? RealStart : FStart;
}
-
- ui64 GetBitLength() const {
- return Length;
- }
-
+
+ ui64 GetBitLength() const {
+ return Length;
+ }
+
protected:
template <ui32 bits>
Y_FORCE_INLINE bool ReadKImpl(ui64& result) {
@@ -45,7 +45,7 @@ namespace NBitIO {
Start = FStart;
return true;
}
-
+
Y_FORCE_INLINE bool ReadImpl(ui64& result, ui32 bits) {
result = (ReadUnaligned<ui64>((const void*)(Start + (BOffset >> 3))) >> (BOffset & 7)) & MaskLowerBits(bits);
BOffset += bits;
@@ -57,13 +57,13 @@ namespace NBitIO {
return false;
}
Start = FStart;
- return true;
- }
-
+ return true;
+ }
+
Y_FORCE_INLINE bool EofImpl() const {
return BOffset >= Length;
}
-
+
Y_FORCE_INLINE ui64 BitOffset() const {
return BOffset;
}
@@ -81,30 +81,30 @@ namespace NBitIO {
Y_FORCE_INLINE static void CopyToResultK(T& result, ui64 r64, ui64 skipbits) {
result = (result & ~(Mask64(bits) << skipbits)) | (r64 << skipbits);
}
-
+
template <typename T>
Y_FORCE_INLINE static void CopyToResult(T& result, ui64 r64, ui64 bits, ui64 skipbits) {
result = (result & InverseMaskLowerBits(bits, skipbits)) | (r64 << skipbits);
}
-
+
public:
template <ui64 bits>
Y_FORCE_INLINE bool ReadWordsImpl(ui64& data) {
data = 0;
-
+
const ui64 haveMore = NthBit64(bits);
const ui64 mask = Mask64(bits);
ui64 current = 0;
ui64 byteNo = 0;
-
+
do {
if (!ReadKImpl<bits + 1>(current))
return false;
-
+
data |= (current & mask) << (byteNo++ * bits);
} while (current & haveMore);
-
+
return true;
}
};
-}
+}