Index: src/ast/ast-value-factory.cc |
diff --git a/src/ast/ast-value-factory.cc b/src/ast/ast-value-factory.cc |
index 4add57955fab4078492593b1c07ee17a653478bd..c666347808b2ca7899b52333ba5eed8aa54fee51 100644 |
--- a/src/ast/ast-value-factory.cc |
+++ b/src/ast/ast-value-factory.cc |
@@ -129,6 +129,36 @@ bool AstRawString::IsOneByteEqualTo(const char* data) const { |
return false; |
} |
+bool AstRawString::Compare(void* a, void* b) { |
+ const AstRawString* lhs = static_cast<AstRawString*>(a); |
+ const AstRawString* rhs = static_cast<AstRawString*>(b); |
+ DCHECK_EQ(lhs->hash(), rhs->hash()); |
+ if (lhs->length() != rhs->length()) return false; |
+ const unsigned char* l = lhs->raw_data(); |
+ const unsigned char* r = rhs->raw_data(); |
+ size_t length = rhs->length(); |
+ if (lhs->is_one_byte()) { |
+ if (rhs->is_one_byte()) { |
+ return CompareCharsUnsigned(reinterpret_cast<const uint8_t*>(l), |
+ reinterpret_cast<const uint8_t*>(r), |
+ length) == 0; |
+ } else { |
+ return CompareCharsUnsigned(reinterpret_cast<const uint8_t*>(l), |
+ reinterpret_cast<const uint16_t*>(r), |
+ length) == 0; |
+ } |
+ } else { |
+ if (rhs->is_one_byte()) { |
+ return CompareCharsUnsigned(reinterpret_cast<const uint16_t*>(l), |
+ reinterpret_cast<const uint8_t*>(r), |
+ length) == 0; |
+ } else { |
+ return CompareCharsUnsigned(reinterpret_cast<const uint16_t*>(l), |
+ reinterpret_cast<const uint16_t*>(r), |
+ length) == 0; |
+ } |
+ } |
+} |
void AstConsString::Internalize(Isolate* isolate) { |
// AstRawStrings are internalized before AstConsStrings so left and right are |
@@ -356,7 +386,7 @@ AstRawString* AstValueFactory::GetString(uint32_t hash, bool is_one_byte, |
// return this AstRawString. |
AstRawString key(is_one_byte, literal_bytes, hash); |
base::HashMap::Entry* entry = string_table_.LookupOrInsert(&key, hash); |
- if (entry->value == NULL) { |
+ if (entry->value == nullptr) { |
// Copy literal contents for later comparison. |
int length = literal_bytes.length(); |
byte* new_literal_bytes = zone_->NewArray<byte>(length); |
@@ -371,36 +401,5 @@ AstRawString* AstValueFactory::GetString(uint32_t hash, bool is_one_byte, |
return reinterpret_cast<AstRawString*>(entry->key); |
} |
- |
-bool AstValueFactory::AstRawStringCompare(void* a, void* b) { |
- const AstRawString* lhs = static_cast<AstRawString*>(a); |
- const AstRawString* rhs = static_cast<AstRawString*>(b); |
- DCHECK_EQ(lhs->hash(), rhs->hash()); |
- if (lhs->length() != rhs->length()) return false; |
- const unsigned char* l = lhs->raw_data(); |
- const unsigned char* r = rhs->raw_data(); |
- size_t length = rhs->length(); |
- if (lhs->is_one_byte()) { |
- if (rhs->is_one_byte()) { |
- return CompareCharsUnsigned(reinterpret_cast<const uint8_t*>(l), |
- reinterpret_cast<const uint8_t*>(r), |
- length) == 0; |
- } else { |
- return CompareCharsUnsigned(reinterpret_cast<const uint8_t*>(l), |
- reinterpret_cast<const uint16_t*>(r), |
- length) == 0; |
- } |
- } else { |
- if (rhs->is_one_byte()) { |
- return CompareCharsUnsigned(reinterpret_cast<const uint16_t*>(l), |
- reinterpret_cast<const uint8_t*>(r), |
- length) == 0; |
- } else { |
- return CompareCharsUnsigned(reinterpret_cast<const uint16_t*>(l), |
- reinterpret_cast<const uint16_t*>(r), |
- length) == 0; |
- } |
- } |
-} |
} // namespace internal |
} // namespace v8 |