diff --git a/db/dbformat.h b/db/dbformat.h index 52f18e6c5..2f5d59e60 100644 --- a/db/dbformat.h +++ b/db/dbformat.h @@ -282,7 +282,7 @@ class IterKey { return Slice(key_, key_size_ - 8); } - size_t Size() { return key_size_; } + size_t Size() const { return key_size_; } void Clear() { key_size_ = 0; } @@ -302,7 +302,7 @@ class IterKey { char* p = new char[total_size]; memcpy(p, key_, shared_len); - if (key_ != nullptr && key_ != space_) { + if (key_ != space_) { delete[] key_; } @@ -388,10 +388,10 @@ class IterKey { char space_[32]; // Avoid allocation for short keys void ResetBuffer() { - if (key_ != nullptr && key_ != space_) { + if (key_ != space_) { delete[] key_; + key_ = space_; } - key_ = space_; buf_size_ = sizeof(space_); key_size_ = 0; } diff --git a/include/rocksdb/write_batch.h b/include/rocksdb/write_batch.h index e0949b51d..a097f2169 100644 --- a/include/rocksdb/write_batch.h +++ b/include/rocksdb/write_batch.h @@ -206,7 +206,8 @@ class WriteBatch : public WriteBatchBase { WriteBatch* GetWriteBatch() override { return this; } // Constructor with a serialized string object - explicit WriteBatch(std::string rep) : save_points_(nullptr), rep_(rep) {} + explicit WriteBatch(const std::string& rep) + : save_points_(nullptr), rep_(rep) {} private: friend class WriteBatchInternal; diff --git a/util/env_posix.cc b/util/env_posix.cc index b856f1d70..4f35f8ed4 100644 --- a/util/env_posix.cc +++ b/util/env_posix.cc @@ -614,19 +614,18 @@ class PosixWritableFile : public WritableFile { virtual Status Append(const Slice& data) override { const char* src = data.data(); size_t left = data.size(); - Status s; - while (left != 0) { - ssize_t done = write(fd_, src, left); - if (done < 0) { - if (errno == EINTR) { - continue; - } - return IOError(filename_, errno); + while (left != 0) { + ssize_t done = write(fd_, src, left); + if (done < 0) { + if (errno == EINTR) { + continue; } - left -= done; - src += done; + return IOError(filename_, errno); } - filesize_ += data.size(); + left -= done; + src += done; + } + filesize_ += data.size(); return Status::OK(); }