ptr.h: use unsigned int to store reference counts (in order to save memory).
authorAlexei Sheplyakov <varg@theor.jinr.ru>
Wed, 15 Oct 2008 06:16:07 +0000 (10:16 +0400)
committerAlexei Sheplyakov <varg@theor.jinr.ru>
Sun, 19 Oct 2008 17:29:11 +0000 (21:29 +0400)
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.

ginac/ptr.h

index c8b0691230bc5c8d8b8c49fc7f7d63620a2387c9..db7f95824864702962d5aa41723ecc8f8a7f01b1 100644 (file)
@@ -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
 };