key_ cannot become nullptr, so no check is needed for that

(ignoring the unlikely case that some overrides
`operator new throw(std::bad_alloc)` with a function that returns a nullptr)
main
jsteemann 9 years ago
parent 834b12a8d5
commit 5ec129971b
  1. 6
      db/dbformat.h

@ -302,7 +302,7 @@ class IterKey {
char* p = new char[total_size]; char* p = new char[total_size];
memcpy(p, key_, shared_len); memcpy(p, key_, shared_len);
if (key_ != nullptr && key_ != space_) { if (key_ != space_) {
delete[] key_; delete[] key_;
} }
@ -388,10 +388,10 @@ class IterKey {
char space_[32]; // Avoid allocation for short keys char space_[32]; // Avoid allocation for short keys
void ResetBuffer() { void ResetBuffer() {
if (key_ != nullptr && key_ != space_) { if (key_ != space_) {
delete[] key_; delete[] key_;
key_ = space_;
} }
key_ = space_;
buf_size_ = sizeof(space_); buf_size_ = sizeof(space_);
key_size_ = 0; key_size_ = 0;
} }

Loading…
Cancel
Save