From ff43212e676047da8839d92a381a8a006f9e7ed3 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Mon, 2 May 2011 14:46:01 +0200 Subject: [PATCH] DVE2: Minor memory compaction. * iface/dve2/dve2.cc (dve2_state, dve2_compressed_state): Store size and count on 16 bits, and hash on 32 bits, to limit memory wasted. --- ChangeLog | 8 ++++++++ iface/dve2/dve2.cc | 18 +++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7de46f4ca..e0a067204 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-05-02 Alexandre Duret-Lutz + + DVE2: Minor memory compaction. + + * iface/dve2/dve2.cc (dve2_state, dve2_compressed_state): Store + size and count on 16 bits, and hash on 32 bits, to limit memory + wasted. + 2011-05-01 Alexandre Duret-Lutz DVE2: Optionally use the new compression. diff --git a/iface/dve2/dve2.cc b/iface/dve2/dve2.cc index cad15940b..bd4c3c5fc 100644 --- a/iface/dve2/dve2.cc +++ b/iface/dve2/dve2.cc @@ -74,7 +74,7 @@ namespace spot struct dve2_state: public state { dve2_state(int s, fixed_size_pool* p) - : size(s), count(1), pool(p) + : pool(p), size(s), count(1) { } @@ -123,17 +123,17 @@ namespace spot } public: - int size; - mutable unsigned count; - size_t hash_value; fixed_size_pool* pool; + size_t hash_value: 32; + int size: 16; + mutable unsigned count: 16; int vars[0]; }; struct dve2_compressed_state: public state { dve2_compressed_state(int s, multiple_size_pool* p) - : size(s), count(1), pool(p) + : pool(p), size(s), count(1) { } @@ -154,7 +154,7 @@ namespace spot { if (--count) return; - pool->deallocate(this, sizeof(*this) + size * sizeof(int)); + pool->deallocate(this, sizeof(*this) + size * sizeof(*vars)); } size_t hash() const @@ -189,10 +189,10 @@ namespace spot } public: - int size; - mutable unsigned count; - size_t hash_value; multiple_size_pool* pool; + size_t hash_value: 32; + int size: 16; + mutable unsigned count: 16; int vars[0]; };