Skip to content

Commit 97eb508

Browse files
victorviannabingtao.yin
authored and
bingtao.yin
committed
Reland changes accidentally reverted in 302786e
These changes 1) 2cc36eb - "[jumbo] Add begin()/end() to Slice." 2) 578eeb7 - "Fix invalid pointer arithmetic in Hash (google#1222)" were committed in the public repository but never got imported to the internal Google repository. Later, cl/713346733 landed in the internal repo. When tooling published the internal change as 302786e ("Fix C++23 compilation errors in leveldb"), it accidentally reverted commits (1) and (2). This change re-commits a bundled version of (1) and (2) in the public repo. This will then be imported to the private repo, leaving the 2 in sync.
1 parent d6e31aa commit 97eb508

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

include/leveldb/slice.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ class LEVELDB_EXPORT Slice {
5151
// Return true iff the length of the referenced data is zero
5252
bool empty() const { return size_ == 0; }
5353

54+
const char* begin() const { return data(); }
55+
const char* end() const { return data() + size(); }
56+
5457
// Return the ith byte in the referenced data.
5558
// REQUIRES: n < size()
5659
char operator[](size_t n) const {

util/hash.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ uint32_t Hash(const char* data, size_t n, uint32_t seed) {
2727
uint32_t h = seed ^ (n * m);
2828

2929
// Pick up four bytes at a time
30-
while (data + 4 <= limit) {
30+
while (limit - data >= 4) {
3131
uint32_t w = DecodeFixed32(data);
3232
data += 4;
3333
h += w;

0 commit comments

Comments
 (0)