Don't flush if not necessary

This commit is contained in:
Sebastian Messmer 2015-04-09 23:29:29 +02:00
parent 4b04226162
commit 628f4edec0
2 changed files with 2 additions and 4 deletions

View File

@ -115,7 +115,6 @@ void DataTree::traverseLeaves(uint32_t beginIndex, uint32_t endIndex, function<v
const_cast<const DataTree*>(this)->traverseLeaves(beginIndex, endIndex, [func](const DataLeafNode* leaf, uint32_t leafIndex) {
func(const_cast<DataLeafNode*>(leaf), leafIndex);
});
flush();
}
void DataTree::traverseLeaves(uint32_t beginIndex, uint32_t endIndex, function<void (const DataLeafNode*, uint32_t)> func) const {
@ -196,7 +195,6 @@ void DataTree::resizeNumBytes(uint64_t newNumBytes) {
}
uint32_t newLastLeafSize = newNumBytes - (newNumLeaves-1)*_nodeStore->layout().maxBytesPerLeaf();
LastLeaf(_rootNode.get())->resize(newLastLeafSize);
flush();
}
assert(newNumBytes == numStoredBytes());
}

View File

@ -35,6 +35,8 @@ public:
uint64_t numStoredBytes() const;
void flush() const;
private:
mutable boost::shared_mutex _mutex;
datanodestore::DataNodeStore *_nodeStore;
@ -61,8 +63,6 @@ private:
cpputils::optional_ownership_ptr<datanodestore::DataLeafNode> LastLeaf(datanodestore::DataNode *root);
std::unique_ptr<datanodestore::DataLeafNode> LastLeaf(std::unique_ptr<datanodestore::DataNode> root);
void flush() const;
DISALLOW_COPY_AND_ASSIGN(DataTree);
};