diff options
Diffstat (limited to 'zenstore/compactcas.h')
| -rw-r--r-- | zenstore/compactcas.h | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/zenstore/compactcas.h b/zenstore/compactcas.h index f9e60aec8..398218cd0 100644 --- a/zenstore/compactcas.h +++ b/zenstore/compactcas.h @@ -45,26 +45,30 @@ struct CasDiskLocation inline CasLocation Get(uint64_t OffsetAlignement) const { - return {.BlockIndex = BlockIndex(), .Offset = Offset() * OffsetAlignement, .Size = Size()}; + uint64_t PackedOffset = 0; + memcpy(&PackedOffset, &m_Offset, sizeof m_Offset); + return {.BlockIndex = static_cast<std::uint32_t>(PackedOffset >> MaxOffsetBits), + .Offset = (PackedOffset & MaxOffset) * OffsetAlignement, + .Size = GetSize()}; } -private: - inline uint32_t BlockIndex() const + inline uint32_t GetBlockIndex() const { uint64_t PackedOffset = 0; memcpy(&PackedOffset, &m_Offset, sizeof m_Offset); return static_cast<std::uint32_t>(PackedOffset >> MaxOffsetBits); } - inline uint64_t Offset() const + inline uint64_t GetOffset() const { uint64_t PackedOffset = 0; memcpy(&PackedOffset, &m_Offset, sizeof m_Offset); return PackedOffset & MaxOffset; } - inline uint64_t Size() const { return m_Size; } + inline uint64_t GetSize() const { return m_Size; } +private: inline void Init(uint32_t BlockIndex, uint64_t Offset, uint64_t Size) { ZEN_ASSERT(BlockIndex <= MaxBlockIndex); |