Chromium Code Reviews| Index: src/ast/ast-value-factory.cc |
| diff --git a/src/ast/ast-value-factory.cc b/src/ast/ast-value-factory.cc |
| index 1e4ef7d37cd1ce5b4a0489b7938669e50c755c16..7673d98fd54e8fbfd7374918012550c63818aabd 100644 |
| --- a/src/ast/ast-value-factory.cc |
| +++ b/src/ast/ast-value-factory.cc |
| @@ -330,11 +330,17 @@ const AstValue* AstValueFactory::NewNumber(double number, bool with_dot) { |
| return AddValue(value); |
| } |
| - |
| -const AstValue* AstValueFactory::NewSmi(int number) { |
| - AstValue* value = |
| - new (zone_) AstValue(AstValue::SMI, number); |
| - return AddValue(value); |
| +const AstValue* AstValueFactory::NewSmi(uint32_t number) { |
|
vogelheim
2016/11/09 15:04:10
[nitpick, and purely a matter of personal preferen
|
| + if (number <= kMaxCachedSmi) { |
| + if (smis_[number] == nullptr) { |
| + AstValue* value = new (zone_) AstValue(AstValue::SMI, number); |
| + smis_[number] = AddValue(value); |
| + } |
| + return smis_[number]; |
| + } else { |
| + AstValue* value = new (zone_) AstValue(AstValue::SMI, number); |
| + return AddValue(value); |
| + } |
| } |
| #define GENERATE_VALUE_GETTER(value, initializer) \ |