diff options
| author | Stefan Boberg <[email protected]> | 2023-04-27 14:35:38 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-04-27 14:35:38 +0200 |
| commit | 88b977d78617c31f61f2a51e96b35ceeb7e9db72 (patch) | |
| tree | 23a34aea9319a9f4dd41fbc39a51a783aeba7f0f /zenstore/blockstore.cpp | |
| parent | bugfixes (#261) (diff) | |
| download | zen-88b977d78617c31f61f2a51e96b35ceeb7e9db72.tar.xz zen-88b977d78617c31f61f2a51e96b35ceeb7e9db72.zip | |
made Ref<> constructor explicit (#262)
This change makes the Ref<> constructor explicit, which can help avoid unnecessary overheads and other accidents
Diffstat (limited to 'zenstore/blockstore.cpp')
| -rw-r--r-- | zenstore/blockstore.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/zenstore/blockstore.cpp b/zenstore/blockstore.cpp index 9738df729..5dfa10c91 100644 --- a/zenstore/blockstore.cpp +++ b/zenstore/blockstore.cpp @@ -177,7 +177,7 @@ BlockStore::Initialize(const std::filesystem::path& BlocksBasePath, } continue; } - Ref<BlockStoreFile> BlockFile = new BlockStoreFile(Path); + Ref<BlockStoreFile> BlockFile{new BlockStoreFile(Path)}; BlockFile->Open(); m_TotalSize.fetch_add(BlockFile->FileSize(), std::memory_order::relaxed); m_ChunkBlocks[BlockIndex] = BlockFile; @@ -215,7 +215,7 @@ BlockStore::WriteChunk(const void* Data, uint64_t Size, uint64_t Alignment, cons RwLock::ExclusiveLockScope InsertLock(m_InsertLock); uint32_t WriteBlockIndex = m_WriteBlockIndex.load(std::memory_order_acquire); - bool IsWriting = m_WriteBlock != nullptr; + bool IsWriting = !!m_WriteBlock; if (!IsWriting || (m_CurrentInsertOffset + Size) > m_MaxBlockSize) { if (m_WriteBlock) @@ -236,7 +236,7 @@ BlockStore::WriteChunk(const void* Data, uint64_t Size, uint64_t Alignment, cons std::filesystem::path BlockPath = GetBlockPath(m_BlocksBasePath, WriteBlockIndex); - Ref<BlockStoreFile> NewBlockFile = new BlockStoreFile(BlockPath); + Ref<BlockStoreFile> NewBlockFile(new BlockStoreFile(BlockPath)); NewBlockFile->Create(m_MaxBlockSize); m_ChunkBlocks[WriteBlockIndex] = NewBlockFile; @@ -486,7 +486,7 @@ BlockStore::ReclaimSpace(const ReclaimSnapshotState& Snapshot, ReadBlockTimeUs += ElapsedUs; ReadBlockLongestTimeUs = std::max(ElapsedUs, ReadBlockLongestTimeUs); }); - if (OldBlockFile != nullptr) + if (OldBlockFile) { m_ChunkBlocks[BlockIndex] = nullptr; ZEN_DEBUG("marking cas block store file '{}' for delete, block #{}", OldBlockFile->GetPath(), BlockIndex); |