Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9662 for code/branches/core6


Ignore:
Timestamp:
Aug 24, 2013, 7:04:40 PM (11 years ago)
Author:
landauf
Message:

use SmallObjectAllocator for ObjectListElements

Location:
code/branches/core6/src/libraries/core/object
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core6/src/libraries/core/object/Listable.cc

    r9661 r9662  
    100100    }
    101101
     102    /* static */ SmallObjectAllocator& Listable::getObjectListElementAllocator()
     103    {
     104        static SmallObjectAllocator allocator(sizeof(ObjectListElement<Listable>), 1024);
     105        return allocator;
     106    }
     107
    102108    /* static */ void Listable::deleteObjectListElement(ObjectListBaseElement* element)
    103109    {
    104         delete element;
     110        element->~ObjectListBaseElement();
     111        Listable::getObjectListElementAllocator().free(element);
    105112    }
    106113}
  • code/branches/core6/src/libraries/core/object/Listable.h

    r9661 r9662  
    6363
    6464        private:
     65            static SmallObjectAllocator& getObjectListElementAllocator();
     66
    6567            template <class T>
    6668            static ObjectListElement<T>* createObjectListElement(T* object)
    6769            {
    68                 return new ObjectListElement<T>(object);
     70                void* chunk = Listable::getObjectListElementAllocator().alloc();
     71                return new (chunk) ObjectListElement<T>(object);
    6972            }
    7073
Note: See TracChangeset for help on using the changeset viewer.