From 31a2d9dcc2b3a519033918e180f81c4e7b9f8e7e Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Tue, 15 Mar 2005 04:56:36 +0000 Subject: new data type flext::AtomListStatic using pre-allocated space if possible fixes for OSX replaced memory-intensive STL maps by custom-made vector/map-container fix for gcc strangeness no more static assignment of symbols (problems with Metrowerks) small fix for gcc fixed bugs in SIMD code for non-power-of-2 lengths fixes for attribute editor (to deal with large dialogs) svn path=/trunk/; revision=2628 --- externals/grill/flext/source/flitem.cpp | 47 +++++++++++++-------------------- 1 file changed, 18 insertions(+), 29 deletions(-) (limited to 'externals/grill/flext/source/flitem.cpp') diff --git a/externals/grill/flext/source/flitem.cpp b/externals/grill/flext/source/flitem.cpp index 92ce01cd..eb307d09 100755 --- a/externals/grill/flext/source/flitem.cpp +++ b/externals/grill/flext/source/flitem.cpp @@ -21,6 +21,7 @@ flext_base::Item::~Item() if(nxt) delete nxt; } +/* flext_base::ItemSet::ItemSet() {} flext_base::ItemSet::~ItemSet() @@ -28,6 +29,7 @@ flext_base::ItemSet::~ItemSet() for(iterator it = begin(); it != end(); ++it) if(it.data()) delete it.data(); } +*/ flext_base::ItemCont::ItemCont(): members(0),memsize(0),size(0),cont(NULL) @@ -64,9 +66,9 @@ void flext_base::ItemCont::Add(Item *item,const t_symbol *tag,int inlet) if(!Contained(inlet)) Resize(inlet+2); ItemSet &set = GetInlet(inlet); - Item *&lst = set[tag]; + Item *lst = set.find(tag); if(!lst) - lst = item; + set.insert(tag,lst = item); else for(;;) if(!lst->nxt) { lst->nxt = item; break; } @@ -80,17 +82,15 @@ bool flext_base::ItemCont::Remove(Item *item,const t_symbol *tag,int inlet,bool if(Contained(inlet)) { ItemSet &set = GetInlet(inlet); - ItemSet::iterator it = set.find(tag); - if(it != set.end()) { - for(Item *lit = it.data(),*prv = NULL; lit; prv = lit,lit = lit->nxt) { - if(lit == item) { - if(prv) prv->nxt = lit->nxt; - else it.data() = lit->nxt; - - lit->nxt = NULL; - if(free) delete lit; - return true; - } + Item *lit = set.find(tag); + for(Item *prv = NULL; lit; prv = lit,lit = lit->nxt) { + if(lit == item) { + if(prv) prv->nxt = lit->nxt; + else set.insert(tag,lit->nxt); + + lit->nxt = NULL; + if(free) delete lit; + return true; } } } @@ -100,30 +100,19 @@ bool flext_base::ItemCont::Remove(Item *item,const t_symbol *tag,int inlet,bool flext_base::Item *flext_base::ItemCont::FindList(const t_symbol *tag,int inlet) { FLEXT_ASSERT(tag); - - if(Contained(inlet)) { - ItemSet &ai = GetInlet(inlet); - ItemSet::iterator as = ai.find(tag); - if(as != ai.end()) return as.data(); - } - return NULL; + return Contained(inlet)?GetInlet(inlet).find(tag):NULL; } // --- class item lists (methods and attributes) ---------------- -typedef DataMap ClassMap; +typedef TableMap ClassMap; static ClassMap classarr[2]; flext_base::ItemCont *flext_base::GetClassArr(t_classid c,int ix) { ClassMap &map = classarr[ix]; - ClassMap::iterator it = map.find(c); - if(it == map.end()) { - ItemCont *cont = new ItemCont; - map[c] = cont; - return cont; - } - else - return it.data(); + ItemCont *cont = map.find(c); + if(!cont) map.insert(c,cont = new ItemCont); + return cont; } -- cgit v1.2.1