Reland "[wasm] Use memcmp to compare module bytes"
This is a reland of 45ea015080
Original change's description:
> [wasm] Use memcmp to compare module bytes
>
> This is much faster than std::lexicographical_compare.
>
> R=clemensb@chromium.org
>
> Bug: chromium:1048554
> Change-Id: I5f0ba22654e172535b6e6fcf6d2a460e278d3cfd
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2036078
> Reviewed-by: Clemens Backes <clemensb@chromium.org>
> Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#66109}
Bug: chromium:1048554
Change-Id: I04d4b1ea8354f7d0567100dec10be0de6ca0ed37
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2037432
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66118}
This commit is contained in:
parent
7a9e7f5084
commit
868e4e19ab
@ -69,8 +69,17 @@ class NativeModuleCache {
|
||||
if (prefix_hash != other.prefix_hash) {
|
||||
return prefix_hash < other.prefix_hash;
|
||||
}
|
||||
return std::lexicographical_compare(
|
||||
bytes.begin(), bytes.end(), other.bytes.begin(), other.bytes.end());
|
||||
if (bytes.size() != other.bytes.size()) {
|
||||
return bytes.size() < other.bytes.size();
|
||||
}
|
||||
// Fast path when the base pointers are the same.
|
||||
// Also handles the {nullptr} case which would be UB for memcmp.
|
||||
if (bytes.begin() == other.bytes.begin()) {
|
||||
return false;
|
||||
}
|
||||
DCHECK_NOT_NULL(bytes.begin());
|
||||
DCHECK_NOT_NULL(other.bytes.begin());
|
||||
return memcmp(bytes.begin(), other.bytes.begin(), bytes.size()) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user