Skip to content

Commit

Permalink
ARROW-85 memcmp can be avoided in Equal when comparing with the same …
Browse files Browse the repository at this point in the history
…Buffer
  • Loading branch information
Kai Zheng committed Apr 4, 2016
1 parent 9d88a50 commit 4d04c27
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cpp/src/arrow/util/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ class Buffer : public std::enable_shared_from_this<Buffer> {
// up to the number of compared bytes
bool Equals(const Buffer& other, int64_t nbytes) const {
return this == &other || (size_ >= nbytes && other.size_ >= nbytes &&
!memcmp(data_, other.data_, nbytes));
(data_ == other.data_ || !memcmp(data_, other.data_, nbytes)));
}

bool Equals(const Buffer& other) const {
return this == &other || (size_ == other.size_ && !memcmp(data_, other.data_, size_));
return this == &other ||
(size_ == other.size_ && (data_ == other.data_ ||
!memcmp(data_, other.data_, size_)));
}

const uint8_t* data() const { return data_; }
Expand Down

0 comments on commit 4d04c27

Please sign in to comment.