diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2014-08-24 02:08:05 +0200 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2014-08-24 02:08:33 +0200 |
commit | b0875eb3fea0934f3a6651fbc22aac12e33e15e5 (patch) | |
tree | 24d1ee392c0b29a61e0b4c09bae780d6ae35866d /src/txdb.cpp | |
parent | 5cd00bc8cb6820d3b41bea329fcf0c26c03db64a (diff) |
Allow BatchWrite to destroy its input, reducing copying
Diffstat (limited to 'src/txdb.cpp')
-rw-r--r-- | src/txdb.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/txdb.cpp b/src/txdb.cpp index d3d05c58d7..7c0683aaf3 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -54,12 +54,15 @@ bool CCoinsViewDB::SetBestBlock(const uint256 &hashBlock) { return db.WriteBatch(batch); } -bool CCoinsViewDB::BatchWrite(const CCoinsMap &mapCoins, const uint256 &hashBlock) { +bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) { LogPrint("coindb", "Committing %u changed transactions to coin database...\n", (unsigned int)mapCoins.size()); CLevelDBBatch batch; - for (CCoinsMap::const_iterator it = mapCoins.begin(); it != mapCoins.end(); it++) + for (CCoinsMap::iterator it = mapCoins.begin(); it != mapCoins.end();) { BatchWriteCoins(batch, it->first, it->second); + CCoinsMap::iterator itOld = it++; + mapCoins.erase(itOld); + } if (hashBlock != uint256(0)) BatchWriteHashBestChain(batch, hashBlock); |