Use Slice == instead of std::memcmp if possible.
GitOrigin-RevId: fc40339f1fa51ad2995f875b5a855bfebfb87b06
This commit is contained in:
parent
f432abcce4
commit
126be85b0f
@ -160,11 +160,11 @@ class Parser {
|
||||
return status_;
|
||||
}
|
||||
|
||||
bool start_with(Slice prefix) {
|
||||
if (prefix.size() + ptr_ > end_) {
|
||||
bool start_with(Slice prefix) const {
|
||||
if (prefix.size() > static_cast<size_t>(end_ - ptr_)) {
|
||||
return false;
|
||||
}
|
||||
return std::memcmp(prefix.begin(), ptr_, prefix.size()) == 0;
|
||||
return prefix == Slice(ptr_, prefix.size());
|
||||
}
|
||||
|
||||
bool skip_start_with(Slice prefix) {
|
||||
|
@ -48,7 +48,7 @@ struct UInt {
|
||||
|
||||
template <size_t size>
|
||||
bool operator==(const UInt<size> &a, const UInt<size> &b) {
|
||||
return std::memcmp(a.raw, b.raw, sizeof(a.raw)) == 0;
|
||||
return a.as_slice() == b.as_slice();
|
||||
}
|
||||
|
||||
template <size_t size>
|
||||
@ -84,7 +84,7 @@ MutableSlice as_slice(UInt<size> &value) {
|
||||
|
||||
template <size_t size>
|
||||
bool operator<(const UInt<size> &a, const UInt<size> &b) {
|
||||
return std::memcmp(a.raw, b.raw, sizeof(a.raw)) < 0;
|
||||
return a.as_slice() < b.as_slice();
|
||||
}
|
||||
|
||||
using UInt128 = UInt<128>;
|
||||
|
@ -24,7 +24,7 @@ bool find_boundary(ChainBufferReader range, Slice boundary, size_t &already_read
|
||||
auto save_range = range.clone();
|
||||
char x[MAX_BOUNDARY_LENGTH + 4];
|
||||
range.advance(boundary.size(), {x, sizeof(x)});
|
||||
if (std::memcmp(x, boundary.data(), boundary.size()) == 0) {
|
||||
if (Slice(x, boundary.size()) == boundary) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user