mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-16 02:42:23 +08:00
Don't copy an empty string in keyAfter and singleKeyRange
This commit is contained in:
parent
cf97541135
commit
248d4e95dd
@ -553,7 +553,9 @@ inline KeyRef keyAfter(const KeyRef& key, Arena& arena) {
|
||||
return allKeysEnd;
|
||||
}
|
||||
uint8_t* t = new (arena) uint8_t[key.size() + 1];
|
||||
memcpy(t, key.begin(), key.size());
|
||||
if (!key.empty()) {
|
||||
memcpy(t, key.begin(), key.size());
|
||||
}
|
||||
t[key.size()] = 0;
|
||||
return KeyRef(t, key.size() + 1);
|
||||
}
|
||||
@ -564,7 +566,9 @@ inline Key keyAfter(const KeyRef& key) {
|
||||
}
|
||||
inline KeyRangeRef singleKeyRange(KeyRef const& key, Arena& arena) {
|
||||
uint8_t* t = new (arena) uint8_t[key.size() + 1];
|
||||
memcpy(t, key.begin(), key.size());
|
||||
if (!key.empty()) {
|
||||
memcpy(t, key.begin(), key.size());
|
||||
}
|
||||
t[key.size()] = 0;
|
||||
return KeyRangeRef(KeyRef(t, key.size()), KeyRef(t, key.size() + 1));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user