mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-02-22 08:28:30 +00:00
Directly use memmem in contains
This commit is contained in:
parent
ee4dad7a13
commit
e13775ec2c
@ -14,14 +14,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
bool byte_view::contains(byte_view pattern) const {
|
bool byte_view::contains(byte_view pattern) const {
|
||||||
if (_buf == nullptr)
|
return _buf != nullptr && memmem(_buf, _sz, pattern._buf, pattern._sz) != nullptr;
|
||||||
return false;
|
|
||||||
for (uint8_t *p = _buf, *eof = _buf + _sz; p < eof; ++p) {
|
|
||||||
if (memcmp(p, pattern.buf(), pattern.sz()) == 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool byte_view::equals(byte_view o) const {
|
bool byte_view::equals(byte_view o) const {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user