X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FGroupVarint.h;h=ad0bb361cf59620e229886ab2696d33152c75618;hb=3579ddb46bf91312e7c1d24389ad60fd96fad776;hp=8160c380b9e08ad24a3751e17c4bc192c1555782;hpb=ed8c80a0e0988e4ce687f51ca832a00e4a6b7930;p=folly.git diff --git a/folly/GroupVarint.h b/folly/GroupVarint.h index 8160c380..ad0bb361 100644 --- a/folly/GroupVarint.h +++ b/folly/GroupVarint.h @@ -16,37 +16,39 @@ #pragma once +#include +#include + +#include + #if !defined(__GNUC__) && !defined(_MSC_VER) #error GroupVarint.h requires GCC or MSVC #endif #include -#if FOLLY_X64 || defined(__i386__) || FOLLY_PPC64 || FOLLY_A64 +#if FOLLY_X64 || defined(__i386__) || FOLLY_PPC64 || FOLLY_AARCH64 #define HAVE_GROUP_VARINT 1 -#include -#include -#include -#include #include +#include +#include #include -#include #if FOLLY_SSE >= 3 #include namespace folly { namespace detail { alignas(16) extern const uint64_t groupVarintSSEMasks[]; -} // namespace detail -} // namespace folly +} // namespace detail +} // namespace folly #endif namespace folly { namespace detail { extern const uint8_t groupVarintLengths[]; -} // namespace detail -} // namespace folly +} // namespace detail +} // namespace folly namespace folly { @@ -105,13 +107,21 @@ class GroupVarint : public detail::GroupVarintBase { uint8_t v = uint8_t(*p); size_t s = kHeaderSize; s += 1 + b0key(v); - if (s > size) return 0; + if (s > size) { + return 0; + } s += 1 + b1key(v); - if (s > size) return 1; + if (s > size) { + return 1; + } s += 1 + b2key(v); - if (s > size) return 2; + if (s > size) { + return 2; + } s += 1 + b3key(v); - if (s > size) return 3; + if (s > size) { + return 3; + } return 4; } @@ -310,15 +320,25 @@ class GroupVarint : public detail::GroupVarintBase { uint16_t v = loadUnaligned(p); size_t s = kHeaderSize; s += 1 + b0key(v); - if (s > size) return 0; + if (s > size) { + return 0; + } s += 1 + b1key(v); - if (s > size) return 1; + if (s > size) { + return 1; + } s += 1 + b2key(v); - if (s > size) return 2; + if (s > size) { + return 2; + } s += 1 + b3key(v); - if (s > size) return 3; + if (s > size) { + return 3; + } s += 1 + b4key(v); - if (s > size) return 4; + if (s > size) { + return 4; + } return 5; } @@ -549,7 +569,7 @@ class GroupVarintDecoder { bool next(type* val) { if (pos_ == count_) { // refill - size_t rem = end_ - p_; + size_t rem = size_t(end_ - p_); if (rem == 0 || remaining_ == 0) { return false; } @@ -581,7 +601,7 @@ class GroupVarintDecoder { } } else { // Can't decode a full group - count_ = Base::partialCount(p_, end_ - p_); + count_ = Base::partialCount(p_, size_t(end_ - p_)); if (remaining_ >= count_) { remaining_ -= count_; p_ = end_; @@ -604,7 +624,7 @@ class GroupVarintDecoder { CHECK(pos_ == count_ && (p_ == end_ || remaining_ == 0)); // p_ may point to the internal buffer (tmp_), but we want // to return subpiece of the original data - size_t size = end_ - p_; + size_t size = size_t(end_ - p_); return StringPiece(rrest_ - size, rrest_); } @@ -623,6 +643,6 @@ class GroupVarintDecoder { typedef GroupVarintDecoder GroupVarint32Decoder; typedef GroupVarintDecoder GroupVarint64Decoder; -} // namespace folly +} // namespace folly #endif /* FOLLY_X64 || defined(__i386__) || FOLLY_PPC64 */