File tree Expand file tree Collapse file tree 4 files changed +12
-0
lines changed
Expand file tree Collapse file tree 4 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -166,6 +166,10 @@ void CDBBatch::Clear()
166166{
167167 m_impl_batch->batch .Clear ();
168168}
169+ void CDBBatch::Reserve (size_t size) const
170+ {
171+ m_impl_batch->batch .Reserve (size);
172+ }
169173size_t CDBBatch::ApproximateSize () const
170174{
171175 return m_impl_batch->batch .ApproximateSize ();
Original file line number Diff line number Diff line change @@ -37,6 +37,10 @@ void WriteBatch::Clear() {
3737 rep_.resize (kHeader );
3838}
3939
40+ void WriteBatch::Reserve (size_t size) {
41+ rep_.reserve (size);
42+ }
43+
4044size_t WriteBatch::ApproximateSize () const { return rep_.size (); }
4145
4246Status WriteBatch::Iterate (Handler* handler) const {
Original file line number Diff line number Diff line change @@ -56,6 +56,9 @@ class LEVELDB_EXPORT WriteBatch {
5656 // Clear all updates buffered in this batch.
5757 void Clear ();
5858
59+ // Preallocate memory for a batch containing a sequence of updates.
60+ void Reserve (size_t size);
61+
5962 // The size of the database changes caused by this batch.
6063 //
6164 // This number is tied to implementation details, and may change across
Original file line number Diff line number Diff line change @@ -92,6 +92,7 @@ std::vector<uint256> CCoinsViewDB::GetHeadBlocks() const {
9292
9393bool CCoinsViewDB::BatchWrite (CoinsViewCacheCursor& cursor, const uint256 &hashBlock) {
9494 CDBBatch batch (*m_db);
95+ batch.Reserve (m_options.batch_write_bytes );
9596
9697 size_t count = 0 ;
9798 size_t changed = 0 ;
You can’t perform that action at this time.
0 commit comments