add WriteBatch::WriteBatch(std::string&&)

Summary:
to save a string copy for some use cases.

The change is pretty straightforward, please feel free to let me know if you want to suggest any tests for it.
Closes https://github.com/facebook/rocksdb/pull/3349

Differential Revision: D6706828

Pulled By: yiwu-arbug

fbshipit-source-id: 873ce4442937bdc030b395c7f99228eda7f59eb7
This commit is contained in:
Bo Liu 2018-01-11 15:35:21 -08:00 committed by Facebook Github Bot
parent d4da02d147
commit 204af1eccc
2 changed files with 7 additions and 0 deletions

View File

@ -144,6 +144,12 @@ WriteBatch::WriteBatch(const std::string& rep)
max_bytes_(0),
rep_(rep) {}
WriteBatch::WriteBatch(std::string&& rep)
: save_points_(nullptr),
content_flags_(ContentFlags::DEFERRED),
max_bytes_(0),
rep_(std::move(rep)) {}
WriteBatch::WriteBatch(const WriteBatch& src)
: save_points_(src.save_points_),
wal_term_point_(src.wal_term_point_),

View File

@ -315,6 +315,7 @@ class WriteBatch : public WriteBatchBase {
// Constructor with a serialized string object
explicit WriteBatch(const std::string& rep);
explicit WriteBatch(std::string&& rep);
WriteBatch(const WriteBatch& src);
WriteBatch(WriteBatch&& src) noexcept;