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/flatom.cpp | 64 +++++++++++++++++---------------- 1 file changed, 33 insertions(+), 31 deletions(-) (limited to 'externals/grill/flext/source/flatom.cpp') diff --git a/externals/grill/flext/source/flatom.cpp b/externals/grill/flext/source/flatom.cpp index 3562e904..bf057c00 100644 --- a/externals/grill/flext/source/flatom.cpp +++ b/externals/grill/flext/source/flatom.cpp @@ -48,33 +48,39 @@ t_atom *flext::CopyList(int argc,const t_atom *argv) return dst; } -flext::AtomList::AtomList(int argc,const t_atom *argv): - cnt(0),lst(NULL) +void flext::AtomList::Alloc(int sz) { - operator()(argc,argv); + if(lst) { + if(cnt == sz) return; // no change + delete[] lst; + } + else + FLEXT_ASSERT(cnt == 0); + lst = new t_atom[cnt = sz]; } -flext::AtomList::AtomList(const AtomList &a): - cnt(0),lst(NULL) +flext::AtomList::~AtomList() { Free(); } + +void flext::AtomList::Free() { - operator =(a); + if(lst) { + delete[] lst; lst = NULL; + cnt = 0; + } + else + FLEXT_ASSERT(cnt == 0); } -flext::AtomList::~AtomList() { Clear(); } - - flext::AtomList &flext::AtomList::Set(int argc,const t_atom *argv,int offs,bool resize) { int ncnt = argc+offs; - if(resize && lst && cnt != ncnt) { delete[] lst; lst = NULL; cnt = 0; } + if(resize) Alloc(ncnt); - if(ncnt) { - if(!lst) lst = new t_atom[cnt = ncnt]; + // argv can be NULL indepently from argc + if(argv) + for(int i = 0; i < argc; ++i) + SetAtom(lst[offs+i],argv[i]); - if(argv) { - for(int i = 0; i < argc; ++i) SetAtom(lst[offs+i],argv[i]); - } - } return *this; } @@ -91,20 +97,16 @@ int flext::AtomList::Compare(const AtomList &a) const return Count() < a.Count()?-1:1; } +flext::AtomListStaticBase::~AtomListStaticBase() { Free(); } -#if FLEXT_SYS != FLEXT_SYS_JMAX -// not for jmax as long as t_symbol * == char * -flext::AtomAnything::AtomAnything(const t_symbol *h,int argc,const t_atom *argv): - AtomList(argc,argv),hdr(h?h:MakeSymbol("")) -{} -#endif - -flext::AtomAnything::AtomAnything(const char *h,int argc,const t_atom *argv): - AtomList(argc,argv),hdr(MakeSymbol(h)) -{} - -flext::AtomAnything::AtomAnything(const AtomAnything &a): - AtomList(a),hdr(a.hdr) -{} - +void flext::AtomListStaticBase::Alloc(int sz) +{ + if(sz < precnt) lst = predata,cnt = sz; + else AtomList::Alloc(sz); +} +void flext::AtomListStaticBase::Free() +{ + if(lst != predata) AtomList::Free(); + else lst = NULL,cnt = 0; +} -- cgit v1.2.1