Changeset 2724


Ignore:
Timestamp:
Nov 19, 2009, 10:52:45 AM (15 years ago)
Author:
strk
Message:

Don not allocate the container of STRtree node childs on the heap

Location:
trunk/source
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/headers/geos/index/strtree/AbstractNode.h

    r2556 r2724  
    3838class GEOS_DLL AbstractNode: public Boundable {
    3939private:
    40         std::vector<Boundable*> *childBoundables;
     40        std::vector<Boundable*> childBoundables;
    4141        int level;
    4242public:
    4343        AbstractNode(int newLevel, int capacity=10);
    4444        virtual ~AbstractNode();
     45
     46        // TODO: change signature to return by ref,
     47        // document ownership of the return
    4548        inline std::vector<Boundable*>* getChildBoundables() {
    46                 return childBoundables;
     49                return &childBoundables;
    4750        }
    4851
     52        // TODO: change signature to return by ref,
     53        // document ownership of the return
    4954        inline const std::vector<Boundable*>* getChildBoundables() const {
    50                 return childBoundables;
     55                return &childBoundables;
    5156        }
    5257
  • trunk/source/index/strtree/AbstractNode.cpp

    r1971 r2724  
    3232 */
    3333AbstractNode::AbstractNode(int newLevel, int capacity) {
    34         childBoundables=new std::vector<Boundable*>();
    35         childBoundables->reserve(capacity);
     34        childBoundables.reserve(capacity);
    3635        bounds=NULL;
    3736        level=newLevel;
     
    3938
    4039AbstractNode::~AbstractNode() {
    41         delete childBoundables;
    4240}
    43 
    44 /**
    45 * Returns either child AbstractNodes, or if this is a leaf node, real data (wrapped
    46 * in ItemBoundables).
    47 */
    48 //vector<Boundable*>* AbstractNode::getChildBoundables() {
    49         //return childBoundables;
    50 //}
    5141
    5242const void *
     
    7363void AbstractNode::addChildBoundable(Boundable *childBoundable) {
    7464        assert(bounds==NULL);
    75         childBoundables->push_back(childBoundable);
     65        childBoundables.push_back(childBoundable);
    7666}
    7767
Note: See TracChangeset for help on using the changeset viewer.