Commit 7e60bc33 authored by jbroman's avatar jbroman Committed by Commit bot

ValueSerializer: add kOneByteString to expected key fast path.

This was missed when Latin-1 encoding replaced UTF-8 encoding when one-byte
strings (like most keys) are serialized.

BUG=chromium:686159

Review-Url: https://codereview.chromium.org/2784423002
Cr-Commit-Position: refs/heads/master@{#44320}
parent 0f9680cd
...@@ -1261,10 +1261,9 @@ bool ValueDeserializer::ReadExpectedString(Handle<String> expected) { ...@@ -1261,10 +1261,9 @@ bool ValueDeserializer::ReadExpectedString(Handle<String> expected) {
// If the bytes are verbatim what is in the flattened string, then the string // If the bytes are verbatim what is in the flattened string, then the string
// is successfully consumed. // is successfully consumed.
if (tag == SerializationTag::kUtf8String && flat.IsOneByte()) { if (tag == SerializationTag::kOneByteString && flat.IsOneByte()) {
Vector<const uint8_t> chars = flat.ToOneByteVector(); Vector<const uint8_t> chars = flat.ToOneByteVector();
if (byte_length == static_cast<size_t>(chars.length()) && if (byte_length == static_cast<size_t>(chars.length()) &&
String::IsAscii(chars.begin(), chars.length()) &&
memcmp(bytes.begin(), chars.begin(), byte_length) == 0) { memcmp(bytes.begin(), chars.begin(), byte_length) == 0) {
return true; return true;
} }
...@@ -1274,6 +1273,13 @@ bool ValueDeserializer::ReadExpectedString(Handle<String> expected) { ...@@ -1274,6 +1273,13 @@ bool ValueDeserializer::ReadExpectedString(Handle<String> expected) {
memcmp(bytes.begin(), chars.begin(), byte_length) == 0) { memcmp(bytes.begin(), chars.begin(), byte_length) == 0) {
return true; return true;
} }
} else if (tag == SerializationTag::kUtf8String && flat.IsOneByte()) {
Vector<const uint8_t> chars = flat.ToOneByteVector();
if (byte_length == static_cast<size_t>(chars.length()) &&
String::IsAscii(chars.begin(), chars.length()) &&
memcmp(bytes.begin(), chars.begin(), byte_length) == 0) {
return true;
}
} }
position_ = original_position; position_ = original_position;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment