Index: src/parsing/parser.cc |
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc |
index 039d924b9737dc8cbde230cdcfe90ba60e22c1b4..db4b1607bbd0fd0479df62017d26753cdf68e693 100644 |
--- a/src/parsing/parser.cc |
+++ b/src/parsing/parser.cc |
@@ -1051,17 +1051,21 @@ FunctionLiteral* Parser::ParseLazy(Isolate* isolate, ParseInfo* info) { |
// Initialize parser state. |
source = String::Flatten(source); |
FunctionLiteral* result; |
- if (source->IsExternalTwoByteString()) { |
- ExternalTwoByteStringUtf16CharacterStream stream( |
- Handle<ExternalTwoByteString>::cast(source), |
- shared_info->start_position(), |
- shared_info->end_position()); |
- result = ParseLazy(isolate, info, &stream); |
- } else { |
- GenericStringUtf16CharacterStream stream(source, |
- shared_info->start_position(), |
- shared_info->end_position()); |
- result = ParseLazy(isolate, info, &stream); |
+ { |
+ std::unique_ptr<Utf16CharacterStream> stream; |
+ if (source->IsExternalTwoByteString()) { |
+ stream.reset(new ExternalTwoByteStringUtf16CharacterStream( |
+ Handle<ExternalTwoByteString>::cast(source), |
+ shared_info->start_position(), shared_info->end_position())); |
+ } else if (source->IsExternalOneByteString()) { |
+ stream.reset(new ExternalOneByteStringUtf16CharacterStream( |
+ Handle<ExternalOneByteString>::cast(source), |
+ shared_info->start_position(), shared_info->end_position())); |
+ } else { |
+ stream.reset(new GenericStringUtf16CharacterStream( |
+ source, shared_info->start_position(), shared_info->end_position())); |
+ } |
+ result = ParseLazy(isolate, info, stream.get()); |
} |
if (FLAG_trace_parse && result != NULL) { |