Skip to content

Commit

Permalink
skip WriteBatch prep for empty transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolay Orliuk committed Oct 23, 2014
1 parent 88c41c6 commit 21efb28
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/leveldb/memory_db.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace leveldb
using map::size;
using map::begin;
using map::end;
using map::empty;

Status Get(const Slice &key, std::string &value) noexcept override
{
Expand Down
2 changes: 2 additions & 0 deletions include/leveldb/txn_db.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ namespace leveldb

Status commit()
{
if (whiteout.empty() || overlay.empty()) return Status::OK();

WriteBatch batch;
for (auto k : whiteout) batch.Delete(k);
for (auto kv : overlay) batch.Put(kv.first, kv.second);
Expand Down
1 change: 1 addition & 0 deletions include/leveldb/whiteout_db.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ namespace leveldb

using set::begin;
using set::end;
using set::empty;

bool Check(const Slice &key)
{ return find(key.ToString()) != end(); }
Expand Down

0 comments on commit 21efb28

Please sign in to comment.