Browse Source
Remove the last vestiges of dlist
Remove the last vestiges of dlist
It served us (mostly) well for more than a decade. It helped KiCad grow before the std:: came into decent shape or speed. It was a good little list. RIP DLIST 2008-2020merge-requests/48/head
20 changed files with 24 additions and 909 deletions
-
1common/CMakeLists.txt
-
5common/base_struct.cpp
-
241common/dlist.cpp
-
1eeschema/lib_item.h
-
1eeschema/sch_eagle_plugin.h
-
3eeschema/sch_line.h
-
2eeschema/sch_painter.cpp
-
2eeschema/schematic_undo_redo.cpp
-
51eeschema/tools/ee_selection_tool.cpp
-
2gerbview/gbr_screen.h
-
5gerbview/gerber_draw_item.h
-
43include/base_struct.h
-
4include/class_board_item.h
-
95include/core/iterators.h
-
262include/dlist.h
-
1include/pcb_screen.h
-
62pcbnew/class_track.cpp
-
10pcbnew/class_track.h
-
10tools/CMakeLists.txt
-
132tools/container_test.cpp
@ -1,241 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2008 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> |
|||
* Copyright (C) 1992-2008 KiCad Developers, see change_log.txt for contributors. |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 2 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|||
* or you may search the http://www.gnu.org website for the version 2 license,
|
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
|
|||
#include <fctsys.h>
|
|||
#include <dlist.h>
|
|||
#include <base_struct.h>
|
|||
|
|||
// verifies conditions for setting a parent list for an element, i.e.
|
|||
// element either does not belong to any list or it already belongs to the same list
|
|||
#define CHECK_OWNERSHIP(a) wxASSERT( !a->GetList() || a->GetList() == this );
|
|||
|
|||
/* Implement the class DHEAD from dlist.h */ |
|||
|
|||
|
|||
DHEAD::~DHEAD() |
|||
{ |
|||
if( meOwner ) |
|||
DeleteAll(); |
|||
} |
|||
|
|||
|
|||
void DHEAD::DeleteAll() |
|||
{ |
|||
wxCHECK( meOwner, /*void*/ ); // only owning lists may delete the contents
|
|||
EDA_ITEM* next; |
|||
EDA_ITEM* item = first; |
|||
|
|||
while( item ) |
|||
{ |
|||
next = item->Next(); |
|||
delete item; // virtual destructor, class specific
|
|||
item = next; |
|||
} |
|||
|
|||
first = 0; |
|||
last = 0; |
|||
count = 0; |
|||
} |
|||
|
|||
|
|||
void DHEAD::append( EDA_ITEM* aNewElement ) |
|||
{ |
|||
wxCHECK( aNewElement, /*void*/ ); |
|||
|
|||
if( first ) // list is not empty, first is not touched
|
|||
{ |
|||
wxASSERT( count > 0 ); |
|||
wxCHECK( last, /*void*/ ); // 'first' is non-null, so 'last' should be non-null too
|
|||
|
|||
aNewElement->SetNext( 0 ); |
|||
aNewElement->SetBack( last ); |
|||
|
|||
wxASSERT( !last->Next() ); // the last element should point to nullptr
|
|||
last->SetNext( aNewElement ); |
|||
last = aNewElement; |
|||
} |
|||
else // list is empty, first and last are changed
|
|||
{ |
|||
wxASSERT( count == 0 ); |
|||
wxASSERT( !last ); // 'first' is null, then 'last' should be too
|
|||
aNewElement->SetNext( 0 ); |
|||
aNewElement->SetBack( 0 ); |
|||
|
|||
first = aNewElement; |
|||
last = aNewElement; |
|||
} |
|||
|
|||
CHECK_OWNERSHIP( aNewElement ); |
|||
aNewElement->SetList( this ); |
|||
|
|||
++count; |
|||
} |
|||
|
|||
|
|||
void DHEAD::append( DHEAD& aList ) |
|||
{ |
|||
if( aList.first ) |
|||
{ |
|||
// Change the item's list to me.
|
|||
for( EDA_ITEM* item = aList.first; item; item = item->Next() ) |
|||
{ |
|||
wxASSERT( item->GetList() == &aList ); |
|||
item->SetList( this ); |
|||
} |
|||
|
|||
if( first ) // this list is not empty, set last item's next to the first item in aList
|
|||
{ |
|||
wxCHECK_RET( last != NULL, wxT( "Last list element not set." ) ); |
|||
|
|||
last->SetNext( aList.first ); |
|||
aList.first->SetBack( last ); |
|||
last = aList.last; |
|||
} |
|||
else // this list is empty, first and last are same as aList
|
|||
{ |
|||
first = aList.first; |
|||
last = aList.last; |
|||
} |
|||
|
|||
count += aList.count; |
|||
|
|||
aList.count = 0; |
|||
aList.first = NULL; |
|||
aList.last = NULL; |
|||
} |
|||
} |
|||
|
|||
|
|||
void DHEAD::insert( EDA_ITEM* aNewElement, EDA_ITEM* aAfterMe ) |
|||
{ |
|||
wxCHECK( aNewElement, /*void*/ ); |
|||
|
|||
if( !aAfterMe ) |
|||
append( aNewElement ); |
|||
else |
|||
{ |
|||
wxCHECK( aAfterMe->GetList() == this, /*void*/ ); |
|||
|
|||
// the list cannot be empty if aAfterMe is supposedly on the list
|
|||
wxASSERT( first && last && count > 0 ); |
|||
|
|||
if( first == aAfterMe ) |
|||
{ |
|||
aAfterMe->SetBack( aNewElement ); |
|||
|
|||
aNewElement->SetBack( 0 ); // first in list does not point back
|
|||
aNewElement->SetNext( aAfterMe ); |
|||
|
|||
first = aNewElement; |
|||
} |
|||
else |
|||
{ |
|||
EDA_ITEM* oldBack = aAfterMe->Back(); |
|||
|
|||
aAfterMe->SetBack( aNewElement ); |
|||
|
|||
aNewElement->SetBack( oldBack ); |
|||
aNewElement->SetNext( aAfterMe ); |
|||
|
|||
oldBack->SetNext( aNewElement ); |
|||
} |
|||
|
|||
CHECK_OWNERSHIP( aNewElement ); |
|||
aNewElement->SetList( this ); |
|||
|
|||
++count; |
|||
} |
|||
} |
|||
|
|||
|
|||
void DHEAD::remove( EDA_ITEM* aElement ) |
|||
{ |
|||
wxCHECK( aElement && aElement->GetList() == this, /*void*/ ); |
|||
|
|||
if( aElement->Next() ) |
|||
{ |
|||
aElement->Next()->SetBack( aElement->Back() ); |
|||
} |
|||
else // element being removed is last
|
|||
{ |
|||
wxASSERT( last == aElement ); |
|||
last = aElement->Back(); |
|||
} |
|||
|
|||
if( aElement->Back() ) |
|||
{ |
|||
aElement->Back()->SetNext( aElement->Next() ); |
|||
} |
|||
else // element being removed is first
|
|||
{ |
|||
wxASSERT( first == aElement ); |
|||
first = aElement->Next(); |
|||
} |
|||
|
|||
aElement->SetBack( 0 ); |
|||
aElement->SetNext( 0 ); |
|||
aElement->SetList( 0 ); |
|||
|
|||
--count; |
|||
wxASSERT( ( first && last ) || count == 0 ); |
|||
} |
|||
|
|||
#if defined(DEBUG)
|
|||
|
|||
void DHEAD::VerifyListIntegrity() |
|||
{ |
|||
EDA_ITEM* item; |
|||
unsigned i = 0; |
|||
|
|||
for( item = first; item && i<count; ++i, item = item->Next() ) |
|||
{ |
|||
if( i < count-1 ) |
|||
{ |
|||
wxASSERT( item->Next() ); |
|||
} |
|||
|
|||
wxASSERT( item->GetList() == this ); |
|||
} |
|||
|
|||
wxASSERT( item == NULL ); |
|||
wxASSERT( i == count ); |
|||
|
|||
i = 0; |
|||
for( item = last; item && i<count; ++i, item = item->Back() ) |
|||
{ |
|||
if( i < count-1 ) |
|||
{ |
|||
wxASSERT( item->Back() ); |
|||
} |
|||
} |
|||
|
|||
wxASSERT( item == NULL ); |
|||
wxASSERT( i == count ); |
|||
|
|||
// printf("list %p has %d items.\n", this, count );
|
|||
} |
|||
|
|||
#endif
|
|||
|
|||
@ -1,95 +0,0 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2016 CERN |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 2 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
|||
* or you may search the http://www.gnu.org website for the version 2 license, |
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
#ifndef __ITERATORS_H |
|||
#define __ITERATORS_H |
|||
|
|||
#include <dlist.h> |
|||
#include <iterator> |
|||
|
|||
template <class T> |
|||
class DLIST_ITERATOR : public std::iterator<std::bidirectional_iterator_tag, T> |
|||
{ |
|||
private: |
|||
T m_obj; |
|||
|
|||
using reference = typename DLIST_ITERATOR<T>::reference; |
|||
|
|||
public: |
|||
explicit DLIST_ITERATOR<T>( T obj ) : |
|||
m_obj(obj) {} |
|||
|
|||
DLIST_ITERATOR<T>& operator++() |
|||
{ |
|||
m_obj = m_obj->Next(); return *this; |
|||
} |
|||
|
|||
DLIST_ITERATOR<T>& operator--() |
|||
{ |
|||
m_obj = m_obj->Prev(); return *this; |
|||
} |
|||
|
|||
bool operator==( DLIST_ITERATOR<T> other ) const |
|||
{ |
|||
return m_obj == other.m_obj; |
|||
} |
|||
|
|||
bool operator!=( DLIST_ITERATOR<T> other ) const |
|||
{ |
|||
return !(*this == other); |
|||
} |
|||
|
|||
reference operator*() |
|||
{ |
|||
return m_obj; |
|||
} |
|||
}; |
|||
|
|||
// helper object, used to convert a DLIST<T> to an iterator |
|||
template <class T> |
|||
class DLIST_ITERATOR_WRAPPER |
|||
{ |
|||
public: |
|||
explicit DLIST_ITERATOR_WRAPPER<T> ( DLIST<T>& list ) : |
|||
m_list(list) {} |
|||
|
|||
DLIST_ITERATOR<T*> begin() |
|||
{ |
|||
return DLIST_ITERATOR<T*> ( m_list.GetFirst() ); |
|||
} |
|||
|
|||
DLIST_ITERATOR<T*> end() |
|||
{ |
|||
return DLIST_ITERATOR<T*> ( nullptr ); |
|||
} |
|||
|
|||
unsigned int Size() const |
|||
{ |
|||
return m_list.GetCount(); |
|||
} |
|||
|
|||
private: |
|||
DLIST<T>& m_list; |
|||
}; |
|||
|
|||
#endif |
|||
@ -1,262 +0,0 @@ |
|||
/* |
|||
* This program source code file is part of KICAD, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2008 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> |
|||
* Copyright (C) 1992-2008 Kicad Developers, see change_log.txt for contributors. |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 2 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
|||
* or you may search the http://www.gnu.org website for the version 2 license, |
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
|
|||
#ifndef DLIST_H_ |
|||
#define DLIST_H_ |
|||
|
|||
|
|||
#include <cstdio> // NULL definition. |
|||
#include <wx/defs.h> // wxDEPRECATED_MSG macro |
|||
|
|||
class EDA_ITEM; |
|||
|
|||
|
|||
/** |
|||
* Class DHEAD |
|||
* is only for use by template class DLIST, use that instead. |
|||
*/ |
|||
class DHEAD |
|||
{ |
|||
protected: |
|||
EDA_ITEM* first; ///< first element in list, or NULL if list empty |
|||
EDA_ITEM* last; ///< last elment in list, or NULL if empty |
|||
unsigned count; ///< how many elements are in the list, automatically maintained. |
|||
bool meOwner; ///< I must delete the objects I hold in my destructor |
|||
|
|||
/** |
|||
* Constructor DHEAD |
|||
* is protected so that a DHEAD can only be instantiated from within a |
|||
* DLIST template. |
|||
*/ |
|||
DHEAD() : |
|||
first(0), |
|||
last(0), |
|||
count(0), |
|||
meOwner(true) |
|||
{ |
|||
} |
|||
|
|||
~DHEAD(); |
|||
|
|||
/** |
|||
* Function append |
|||
* adds \a aNewElement to the end of the list. |
|||
* @param aNewElement The element to insert. |
|||
*/ |
|||
void append( EDA_ITEM* aNewElement ); |
|||
|
|||
/** |
|||
* Function append |
|||
* adds \a aList to the end of the list. |
|||
* @param aList The list to aList. |
|||
*/ |
|||
void append( DHEAD& aList ); |
|||
|
|||
/** |
|||
* Function insert |
|||
* puts \a aNewElement just in front of \a aElementAfterMe in the list sequence. |
|||
* If \a aElementAfterMe is NULL, then simply append(). |
|||
* @param aNewElement The element to insert. |
|||
* @param aElementAfterMe The element to insert \a aNewElement before, |
|||
* if NULL then append \a aNewElement onto end of list. |
|||
*/ |
|||
void insert( EDA_ITEM* aNewElement, EDA_ITEM* aElementAfterMe ); |
|||
|
|||
/** |
|||
* Function insert |
|||
* puts \a aNewElement in front of list sequence. |
|||
* @param aNewElement The element to insert. |
|||
*/ |
|||
void insert( EDA_ITEM* aNewElement ) |
|||
{ |
|||
insert( aNewElement, first ); |
|||
} |
|||
|
|||
/** |
|||
* Function remove |
|||
* removes \a aElement from the list, but does not delete it. |
|||
* @param aElement The element to remove. |
|||
*/ |
|||
void remove( EDA_ITEM* aElement ); |
|||
|
|||
|
|||
public: |
|||
|
|||
/** |
|||
* Function DeleteAll |
|||
* deletes all items on the list and leaves the list empty. The destructor |
|||
* for each item is called. |
|||
*/ |
|||
void DeleteAll(); |
|||
|
|||
/** |
|||
* Function SetOwnership |
|||
* controls whether the list owns the objects and is responsible for |
|||
* deleteing their memory at time of this object's destruction. |
|||
*/ |
|||
void SetOwnership( bool Iown ) { meOwner = Iown; } |
|||
|
|||
|
|||
/** |
|||
* Function GetCount |
|||
* returns the number of elements in the list. |
|||
*/ |
|||
unsigned GetCount() const { return count; } |
|||
|
|||
#if defined(DEBUG) |
|||
void VerifyListIntegrity(); |
|||
#endif |
|||
}; |
|||
|
|||
|
|||
/** |
|||
* Class DLIST |
|||
* is the head of a doubly linked list. It contains pointers to the first |
|||
* and last elements in a doubly linked list. The elements in the list must |
|||
* be of class T or derived from T, and T must be derived from EDA_ITEM. |
|||
* @see DHEAD for additional public functions. |
|||
*/ |
|||
template <class T> |
|||
class |
|||
#if !defined( EESCHEMA ) |
|||
wxDEPRECATED_MSG( "DLIST is deprecated, do not use in new code" ) |
|||
#endif |
|||
DLIST : public DHEAD |
|||
{ |
|||
public: |
|||
|
|||
/** |
|||
* operator T* |
|||
* is a casting operator that returns \a GetFirst(), a T* |
|||
*/ |
|||
operator T* () const { return GetFirst(); } |
|||
|
|||
/** |
|||
* operator -> |
|||
* is a dereferencing operator that returns \a GetFirst(), a T* |
|||
*/ |
|||
T* operator -> () const { return GetFirst(); } |
|||
|
|||
/** |
|||
* Function GetFirst |
|||
* returns the first T* in the list without removing it, or NULL if |
|||
* the list is empty. |
|||
*/ |
|||
T* GetFirst() const { return (T*) first; } |
|||
|
|||
/** |
|||
* Function GetLast |
|||
* returns the last T* in the list without removing it, |
|||
* or NULL if the list is empty. |
|||
*/ |
|||
T* GetLast() const { return (T*) last; } |
|||
|
|||
/** |
|||
* Function Append |
|||
* adds \a aNewElement to the end of the list. |
|||
* @param aNewElement The element to insert. |
|||
*/ |
|||
void Append( T* aNewElement ) |
|||
{ |
|||
append( aNewElement ); |
|||
} |
|||
|
|||
/** |
|||
* Function Append |
|||
* adds \a aList to the end of the list. |
|||
* @param aList The list to append to the end of the list. |
|||
*/ |
|||
void Append( DLIST& aList ) |
|||
{ |
|||
append( aList ); |
|||
} |
|||
|
|||
/** |
|||
* Function Insert |
|||
* puts \a aNewElement just in front of \a aElementAfterMe in the list sequence. |
|||
* If aElementAfterMe is NULL, then simply Append() |
|||
* @param aNewElement The element to insert. |
|||
* @param aElementAfterMe The element to insert \a aNewElement before, |
|||
* if NULL then append \a aNewElement onto end of list. |
|||
*/ |
|||
void Insert( T* aNewElement, T* aElementAfterMe ) |
|||
{ |
|||
insert( aNewElement, aElementAfterMe ); |
|||
} |
|||
|
|||
/** |
|||
* Function Remove |
|||
* removes \a aElement from the list, but does not delete it. |
|||
* @param aElement The element to remove from the list. |
|||
* @return T* - the removed element, so you can easily delete it upon return. |
|||
*/ |
|||
T* Remove( T* aElement ) |
|||
{ |
|||
remove( aElement ); |
|||
return aElement; |
|||
} |
|||
|
|||
//-----< STL like functions >--------------------------------------- |
|||
T* begin() const { return GetFirst(); } |
|||
T* end() const { return GetLast(); } |
|||
|
|||
T* PopFront() |
|||
{ |
|||
if( GetFirst() ) |
|||
return Remove( GetFirst() ); |
|||
return NULL; |
|||
} |
|||
|
|||
T* PopBack() |
|||
{ |
|||
if( GetLast() ) |
|||
return Remove( GetLast() ); |
|||
return NULL; |
|||
} |
|||
|
|||
/** |
|||
* Function PushFront |
|||
* puts aNewElement at front of list sequence. |
|||
* @param aNewElement The element to insert at the front of the list. |
|||
*/ |
|||
void PushFront( T* aNewElement ) |
|||
{ |
|||
insert( aNewElement ); |
|||
} |
|||
|
|||
/** |
|||
* Function PushBack |
|||
* puts aNewElement at the end of the list sequence. |
|||
* @param aNewElement The element to push to the end of the list. |
|||
*/ |
|||
void PushBack( T* aNewElement ) |
|||
{ |
|||
append( aNewElement ); |
|||
} |
|||
|
|||
//-----</ STL like functions >-------------------------------------- |
|||
}; |
|||
|
|||
#endif // DLIST_H_ |
|||
@ -1,132 +0,0 @@ |
|||
|
|||
#include <base_struct.h>
|
|||
#include <boost/ptr_container/ptr_vector.hpp>
|
|||
#include <deque>
|
|||
#include <dlist.h>
|
|||
#include <time.h>
|
|||
#include <common.h>
|
|||
|
|||
#define TEST_NODES 100000000
|
|||
|
|||
|
|||
//typedef std::vector<EDA_ITEM*> EDA_ITEMV;
|
|||
//typedef std::deque<EDA_ITEM*> EDA_ITEMV;
|
|||
typedef boost::ptr_vector<EDA_ITEM> EDA_ITEMV; |
|||
|
|||
class MY_ITEM : public EDA_ITEM |
|||
{ |
|||
public: |
|||
|
|||
MY_ITEM( KICAD_T id ) : |
|||
EDA_ITEM( id ) |
|||
{} |
|||
|
|||
|
|||
#if defined(DEBUG)
|
|||
void Show( int nestLevel, std::ostream& os ) const |
|||
{ |
|||
ShowDummy( os ); |
|||
} |
|||
#endif
|
|||
}; |
|||
|
|||
|
|||
void heap_warm_up(); |
|||
|
|||
int main( int argc, char** argv ) |
|||
{ |
|||
EDA_ITEMV v; |
|||
DLIST<EDA_ITEM> dlist; |
|||
|
|||
unsigned vAllocStart; |
|||
unsigned vAllocStop; |
|||
unsigned vIterateStart; |
|||
unsigned vIterateStop; |
|||
|
|||
unsigned dAllocStart; |
|||
unsigned dAllocStop; |
|||
unsigned dIterateStart; |
|||
unsigned dIterateStop; |
|||
|
|||
heap_warm_up(); |
|||
|
|||
vAllocStart = GetRunningMicroSecs(); |
|||
|
|||
for( int i=0; i<TEST_NODES; ++i ) |
|||
{ |
|||
v.push_back( new MY_ITEM( NOT_USED ) ); |
|||
} |
|||
|
|||
vAllocStop = GetRunningMicroSecs(); |
|||
vIterateStart = vAllocStop; |
|||
|
|||
for( EDA_ITEMV::const_iterator it = v.begin(); it != v.end(); ++it ) |
|||
{ |
|||
if( it->Type() == -22 ) |
|||
{ |
|||
printf( "never this\n" ); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
vIterateStop = GetRunningMicroSecs(); |
|||
|
|||
#if 0
|
|||
for( int i=0; i<TEST_NODES; ++i ) |
|||
{ |
|||
delete v[i]; |
|||
} |
|||
#endif
|
|||
|
|||
v.clear(); |
|||
|
|||
|
|||
dAllocStart = GetRunningMicroSecs(); |
|||
|
|||
for( int i=0; i<TEST_NODES; ++i ) |
|||
{ |
|||
dlist.PushBack( new MY_ITEM( NOT_USED ) ); |
|||
} |
|||
|
|||
dAllocStop = GetRunningMicroSecs(); |
|||
dIterateStart = dAllocStop; |
|||
|
|||
for( const EDA_ITEM* it = dlist; it; it = it->Next() ) |
|||
{ |
|||
if( it->Type() == -22 ) |
|||
{ |
|||
printf( "never this\n" ); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
dIterateStop = GetRunningMicroSecs(); |
|||
|
|||
printf( "vector alloc: %u usecs iterate: %u usecs\n", |
|||
vAllocStop - vAllocStart, |
|||
vIterateStop - vIterateStart ); |
|||
|
|||
printf( "dlist alloc: %u usecs iterate: %u usecs\n", |
|||
dAllocStop - dAllocStart, |
|||
dIterateStop - dIterateStart ); |
|||
} |
|||
|
|||
|
|||
void heap_warm_up() |
|||
{ |
|||
// dry run allocate enough object for process to obtain all memory needed
|
|||
|
|||
EDA_ITEMV vec; |
|||
|
|||
for( int i=0; i<TEST_NODES; ++i ) |
|||
{ |
|||
vec.push_back( new MY_ITEM( NOT_USED ) ); |
|||
} |
|||
|
|||
for( int i=0; i<TEST_NODES; ++i ) |
|||
{ |
|||
// delete vec[i];
|
|||
} |
|||
|
|||
vec.clear(); |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue