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}
This commit is contained in:
jbroman 2017-03-31 18:40:39 -07:00 committed by Commit bot
parent 0f9680cd2d
commit 7e60bc3378

View File

@ -1261,10 +1261,9 @@ bool ValueDeserializer::ReadExpectedString(Handle<String> expected) {
// If the bytes are verbatim what is in the flattened string, then the string
// is successfully consumed.
if (tag == SerializationTag::kUtf8String && flat.IsOneByte()) {
if (tag == SerializationTag::kOneByteString && 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;
}
@ -1274,6 +1273,13 @@ bool ValueDeserializer::ReadExpectedString(Handle<String> expected) {
memcmp(bytes.begin(), chars.begin(), byte_length) == 0) {
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;