From: Alexei Sheplyakov Date: Wed, 15 Oct 2008 06:16:07 +0000 (+0400) Subject: ptr.h: use unsigned int to store reference counts (in order to save memory). X-Git-Tag: release_1-5-0~52 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=ce9053c15affb2a1a99d1157b85266d70aec601b ptr.h: use unsigned int to store reference counts (in order to save memory). We'll hardly ever get more than 2^32 references to the same object. So using size_t to store reference count only wastes 4 bytes per object (on 64-bit architecture). Use unsigned int instead. --- diff --git a/ginac/ptr.h b/ginac/ptr.h index c8b06912..db7f9582 100644 --- a/ginac/ptr.h +++ b/ginac/ptr.h @@ -37,13 +37,13 @@ class refcounted { public: refcounted() throw() : refcount(0) {} - size_t add_reference() throw() { return ++refcount; } - size_t remove_reference() throw() { return --refcount; } - size_t get_refcount() const throw() { return refcount; } - void set_refcount(size_t r) throw() { refcount = r; } + unsigned int add_reference() throw() { return ++refcount; } + unsigned int remove_reference() throw() { return --refcount; } + unsigned int get_refcount() const throw() { return refcount; } + void set_refcount(unsigned int r) throw() { refcount = r; } private: - size_t refcount; ///< reference counter + unsigned int refcount; ///< reference counter };