From 9cb4c68b89a5715f82026f4aa446b876addd8472 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Fri, 6 Oct 2023 11:35:15 +0200 Subject: [PATCH] serialize: make GetSizeOfCompactSize constexpr --- src/serialize.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/serialize.h b/src/serialize.h index e53ff9fa4c9..8b15178ec07 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -316,7 +316,7 @@ template inline void Unserialize(Stream& s, bool& a) { uint8_t * size <= UINT_MAX -- 5 bytes (254 + 4 bytes) * size > UINT_MAX -- 9 bytes (255 + 8 bytes) */ -inline unsigned int GetSizeOfCompactSize(uint64_t nSize) +constexpr inline unsigned int GetSizeOfCompactSize(uint64_t nSize) { if (nSize < 253) return sizeof(unsigned char); else if (nSize <= std::numeric_limits::max()) return sizeof(unsigned char) + sizeof(uint16_t);