Avoid excessive resizing.

This commit is contained in:
JoelKatz
2013-03-14 10:00:44 -07:00
parent e56f7a8689
commit 82b91a1c41
2 changed files with 4 additions and 2 deletions

View File

@@ -309,6 +309,7 @@ void ValidationCollection::doWrite(Job&)
while (!mStaleValidations.empty())
{
std::vector<SerializedValidation::pointer> vector;
vector.reserve(512);
mStaleValidations.swap(vector);
sl.unlock();
{

View File

@@ -20,7 +20,7 @@ class ValidationCollection
{
protected:
boost::mutex mValidationLock;
boost::mutex mValidationLock;
TaggedCache<uint256, ValidationSet> mValidations;
boost::unordered_map<uint160, SerializedValidation::pointer> mCurrentValidations;
std::vector<SerializedValidation::pointer> mStaleValidations;
@@ -34,7 +34,8 @@ protected:
boost::shared_ptr<ValidationSet> findSet(const uint256& ledgerHash);
public:
ValidationCollection() : mValidations("Validations", 128, 600), mWriting(false) { ; }
ValidationCollection() : mValidations("Validations", 128, 600), mWriting(false)
{ mStaleValidations.reserve(512); }
bool addValidation(SerializedValidation::ref);
ValidationSet getValidations(const uint256& ledger);