Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 break; | 215 break; |
| 216 case UNDEFINED: | 216 case UNDEFINED: |
| 217 set_value(isolate->factory()->undefined_value()); | 217 set_value(isolate->factory()->undefined_value()); |
| 218 break; | 218 break; |
| 219 } | 219 } |
| 220 } | 220 } |
| 221 | 221 |
| 222 | 222 |
| 223 AstRawString* AstValueFactory::GetOneByteStringInternal( | 223 AstRawString* AstValueFactory::GetOneByteStringInternal( |
| 224 Vector<const uint8_t> literal) { | 224 Vector<const uint8_t> literal) { |
| 225 if (literal.length() == 1 && literal[0] >= 'a' && literal[0] <= 'z') { | |
|
Toon Verwaest
2016/12/05 15:30:40
IsInRange(literal[0], 'a', 'z') is faster ;)
marja
2016/12/08 15:09:59
Done.
| |
| 226 int key = literal[0] - 'a'; | |
| 227 if (one_character_strings_[key] == nullptr) { | |
| 228 uint32_t hash = StringHasher::HashSequentialString<uint8_t>( | |
|
Toon Verwaest
2016/12/05 15:30:40
We could just have a-z heapstrings preallocated in
marja
2016/12/08 15:09:59
Hmm yeah, sounds like a good idea to keep the CLs
| |
| 229 literal.start(), literal.length(), hash_seed_); | |
| 230 one_character_strings_[key] = GetString(hash, true, literal); | |
| 231 } | |
| 232 return one_character_strings_[key]; | |
| 233 } | |
| 225 uint32_t hash = StringHasher::HashSequentialString<uint8_t>( | 234 uint32_t hash = StringHasher::HashSequentialString<uint8_t>( |
| 226 literal.start(), literal.length(), hash_seed_); | 235 literal.start(), literal.length(), hash_seed_); |
| 227 return GetString(hash, true, literal); | 236 return GetString(hash, true, literal); |
| 228 } | 237 } |
| 229 | 238 |
| 230 | 239 |
| 231 AstRawString* AstValueFactory::GetTwoByteStringInternal( | 240 AstRawString* AstValueFactory::GetTwoByteStringInternal( |
| 232 Vector<const uint16_t> literal) { | 241 Vector<const uint16_t> literal) { |
| 233 uint32_t hash = StringHasher::HashSequentialString<uint16_t>( | 242 uint32_t hash = StringHasher::HashSequentialString<uint16_t>( |
| 234 literal.start(), literal.length(), hash_seed_); | 243 literal.start(), literal.length(), hash_seed_); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 420 length) == 0; | 429 length) == 0; |
| 421 } else { | 430 } else { |
| 422 return CompareCharsUnsigned(reinterpret_cast<const uint16_t*>(l), | 431 return CompareCharsUnsigned(reinterpret_cast<const uint16_t*>(l), |
| 423 reinterpret_cast<const uint16_t*>(r), | 432 reinterpret_cast<const uint16_t*>(r), |
| 424 length) == 0; | 433 length) == 0; |
| 425 } | 434 } |
| 426 } | 435 } |
| 427 } | 436 } |
| 428 } // namespace internal | 437 } // namespace internal |
| 429 } // namespace v8 | 438 } // namespace v8 |
| OLD | NEW |