[commit] r1111 - in trunk/GME: Common Core
GMESRC Repository Notifications
gme-commit at list.isis.vanderbilt.edu
Wed Dec 29 11:46:57 CST 2010
Author: ksmyth
Date: Wed Dec 29 11:46:57 2010
New Revision: 1111
Log:
If were copying to a vector, reserve() can increase performance
Modified:
trunk/GME/Common/CommonCollection.h
trunk/GME/Core/CoreAttribute.cpp
trunk/GME/Core/CoreBinFile.cpp
trunk/GME/Core/CoreObject.cpp
Modified: trunk/GME/Common/CommonCollection.h
==============================================================================
--- trunk/GME/Common/CommonCollection.h Tue Dec 28 09:12:31 2010 (r1110)
+++ trunk/GME/Common/CommonCollection.h Wed Dec 29 11:46:57 2010 (r1111)
@@ -228,6 +228,21 @@
}
}
+ template<class COLLTYPE_>
+ void Reserve(COLLTYPE_& col, size_t num_additional) { }
+ template<>
+ void Reserve(std::vector<ITFTYPE*>& col, size_t num_additional)
+ {
+ col.reserve(col.size() + num_additional);
+ }
+
+ template<class COLLTYPE2>
+ void FillAll(COLLTYPE2& col)
+ {
+ Reserve(m_coll, col.size());
+ Fill(col.begin(), col.end());
+ }
+
void Add(OBJTYPE *i)
{
ASSERT( i != NULL );
Modified: trunk/GME/Core/CoreAttribute.cpp
==============================================================================
--- trunk/GME/Core/CoreAttribute.cpp Tue Dec 28 09:12:31 2010 (r1110)
+++ trunk/GME/Core/CoreAttribute.cpp Wed Dec 29 11:46:57 2010 (r1111)
@@ -1895,7 +1895,7 @@
++i;
}
- p->Fill(collection.begin(), collection.end());
+ p->FillAll(collection);
v.pdispVal = p.Detach();
v.vt = VT_DISPATCH;
Modified: trunk/GME/Core/CoreBinFile.cpp
==============================================================================
--- trunk/GME/Core/CoreBinFile.cpp Tue Dec 28 09:12:31 2010 (r1110)
+++ trunk/GME/Core/CoreBinFile.cpp Wed Dec 29 11:46:57 2010 (r1111)
@@ -295,6 +295,7 @@
// TODO: this move could be avoided
binattrs.push_back(std::move(binattrspace));
}
+ ASSERT(binattrs.size() == num_attrs);
};
void BinObject::Write(CCoreBinFile *binfile)
Modified: trunk/GME/Core/CoreObject.cpp
==============================================================================
--- trunk/GME/Core/CoreObject.cpp Tue Dec 28 09:12:31 2010 (r1110)
+++ trunk/GME/Core/CoreObject.cpp Wed Dec 29 11:46:57 2010 (r1111)
@@ -169,7 +169,7 @@
CComObjPtr<COMTYPE> q;
CreateComObject(q);
- q->Fill(attributes.begin(), attributes.end());
+ q->FillAll(attributes);
MoveTo(q,p);
}
COMCATCH(;)
More information about the gme-commit
mailing list