Skip to content

Commit eda924a

Browse files
committed
Remove an unused GetLengthPrefixedSlice
Summary: We have 3 versions of GetLengthPrefixedSlice() and one of them is no longer in use. Test Plan: make Reviewers: sdong, igor, haobo, dhruba CC: leveldb Differential Revision: https://reviews.facebook.net/D15399
1 parent 054c5dd commit eda924a

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

util/coding.h

+3-12
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ extern void PutLengthPrefixedSliceParts(std::string* dst,
3939
extern bool GetVarint32(Slice* input, uint32_t* value);
4040
extern bool GetVarint64(Slice* input, uint64_t* value);
4141
extern bool GetLengthPrefixedSlice(Slice* input, Slice* result);
42+
// This function assumes data is well-formed.
4243
extern Slice GetLengthPrefixedSlice(const char* data);
4344

4445
extern Slice GetSliceUntil(Slice* slice, char delimiter);
@@ -249,16 +250,6 @@ inline bool GetVarint64(Slice* input, uint64_t* value) {
249250
}
250251
}
251252

252-
inline const char* GetLengthPrefixedSlice(const char* p, const char* limit,
253-
Slice* result) {
254-
uint32_t len = 0;
255-
p = GetVarint32Ptr(p, limit, &len);
256-
if (p == nullptr) return nullptr;
257-
if (p + len > limit) return nullptr;
258-
*result = Slice(p, len);
259-
return p + len;
260-
}
261-
262253
inline bool GetLengthPrefixedSlice(Slice* input, Slice* result) {
263254
uint32_t len = 0;
264255
if (GetVarint32(input, &len) && input->size() >= len) {
@@ -272,8 +263,8 @@ inline bool GetLengthPrefixedSlice(Slice* input, Slice* result) {
272263

273264
inline Slice GetLengthPrefixedSlice(const char* data) {
274265
uint32_t len = 0;
275-
const char* p = data;
276-
p = GetVarint32Ptr(p, p + 5, &len); // +5: we assume "p" is not corrupted
266+
// +5: we assume "data" is not corrupted
267+
auto p = GetVarint32Ptr(data, data + 5 /* limit */, &len);
277268
return Slice(p, len);
278269
}
279270

0 commit comments

Comments
 (0)