From a3224e11101ad77dcc3f19127cec00e396d90af1 Mon Sep 17 00:00:00 2001 From: vng Date: Tue, 3 Jan 2012 15:45:56 +0300 Subject: [PATCH] Add some assertions to Cache. --- base/cache.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/base/cache.hpp b/base/cache.hpp index 043f97f0f2..7787236cda 100644 --- a/base/cache.hpp +++ b/base/cache.hpp @@ -12,6 +12,7 @@ namespace my private: Cache(Cache const &); // Not implemented. Cache & operator = (Cache const &); // Not implemented. + public: // Create cache with maximum size @maxCachedObjects. explicit Cache(uint32_t logCacheSize) @@ -19,8 +20,11 @@ namespace my { STATIC_ASSERT((is_same::value || is_same::value)); - CHECK_GREATER(logCacheSize, 1, ()); + + CHECK_GREATER ( logCacheSize, 0, () ); + CHECK_GREATER ( m_HashMask, 0, () ); CHECK_LESS(logCacheSize, 32, ()); + uint32_t const cacheSize = 1 << logCacheSize; // Initialize m_Cache such, that (Hash(m_Cache[i].m_Key) & m_HashMask) != i. for (uint32_t i = 0; i < cacheSize; ++i)