[core] Use constexpr when possible

Signed-off-by: x7z4w <x7z4w@noreply.codeberg.org>
This commit is contained in:
x7z4w
2025-10-24 08:36:38 +00:00
parent 936e05283c
commit 42f059f8f7
90 changed files with 258 additions and 259 deletions

View File

@@ -10,11 +10,11 @@
namespace
{
size_t const kNumBytes = 256;
size_t constexpr kNumBytes = 256;
// Fake trailing '$' for the BWT, used for original string
// reconstruction.
uint32_t const kEOS = 256;
uint32_t constexpr kEOS = 256;
// FirstColumn represents the first column in the BWT matrix. As
// during reverse BWT we need to reconstruct canonical first column,

View File

@@ -414,7 +414,7 @@ unique_ptr<CompressedBitVector> CompressedBitVectorBuilder::FromBitPositions(vec
// static
unique_ptr<CompressedBitVector> CompressedBitVectorBuilder::FromBitGroups(vector<uint64_t> && bitGroups)
{
static uint64_t const kBlockSize = DenseCBV::kBlockSize;
static uint64_t constexpr kBlockSize = DenseCBV::kBlockSize;
while (!bitGroups.empty() && bitGroups.back() == 0)
bitGroups.pop_back();

View File

@@ -89,7 +89,7 @@ class DenseCBV : public CompressedBitVector
{
public:
friend class CompressedBitVectorBuilder;
static uint64_t const kBlockSize = 64;
static uint64_t constexpr kBlockSize = 64;
DenseCBV() = default;

View File

@@ -34,7 +34,7 @@ public:
/// this value.
///
/// WARNING! Existing sections may not be properly aligned.
static uint64_t const kSectionAlignment = 8;
static uint64_t constexpr kSectionAlignment = 8;
bool IsExist(Tag const & tag) const { return GetInfo(tag) != 0; }

View File

@@ -4,7 +4,7 @@
namespace impl
{
static char const kToHexTable[] = "0123456789ABCDEF";
static char constexpr kToHexTable[] = "0123456789ABCDEF";
void ToHexRaw(void const * src, size_t size, void * dst)
{

View File

@@ -100,7 +100,7 @@ void HuffmanCoder::SetDepths(Node * root, uint32_t depth)
// One would need more than 2^32 symbols to build a code that long.
// On the other hand, 32 is short enough for our purposes, so do not
// try to shrink the trees beyond this threshold.
uint32_t const kMaxDepth = 32;
uint32_t constexpr kMaxDepth = 32;
if (!root)
return;

View File

@@ -39,7 +39,7 @@ public:
}
private:
uint32_t static const kBufferSize = 16 * 1024;
uint32_t static constexpr kBufferSize = 16 * 1024;
uint64_t m_res = 0;
uint64_t m_numRead = 0;

View File

@@ -212,7 +212,7 @@ private:
class BlockedTextStorageReader
{
public:
inline static size_t const kDefaultCacheSize = 32;
inline static size_t constexpr kDefaultCacheSize = 32;
BlockedTextStorageReader() : m_cache(kDefaultCacheSize) {}
explicit BlockedTextStorageReader(size_t cacheSize) : m_cache(cacheSize) {}