Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Unified Diff: src/parsing/parser.cc

Issue 2184393002: Implement a character stream for external one byte streams (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/parsing/scanner-character-streams.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index 65271d9a5c3fcebd28baf1a2425d5295573c0fa5..039d924b9737dc8cbde230cdcfe90ba60e22c1b4 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -888,17 +888,19 @@ FunctionLiteral* Parser::ParseProgram(Isolate* isolate, ParseInfo* info) {
source = String::Flatten(source);
FunctionLiteral* result;
- if (source->IsExternalTwoByteString()) {
- // Notice that the stream is destroyed at the end of the branch block.
- // The last line of the blocks can't be moved outside, even though they're
- // identical calls.
- ExternalTwoByteStringUtf16CharacterStream stream(
- Handle<ExternalTwoByteString>::cast(source), 0, source->length());
- scanner_.Initialize(&stream);
- result = DoParseProgram(info);
- } else {
- GenericStringUtf16CharacterStream stream(source, 0, source->length());
- scanner_.Initialize(&stream);
+ {
+ std::unique_ptr<Utf16CharacterStream> stream;
+ if (source->IsExternalTwoByteString()) {
+ stream.reset(new ExternalTwoByteStringUtf16CharacterStream(
+ Handle<ExternalTwoByteString>::cast(source), 0, source->length()));
+ } else if (source->IsExternalOneByteString()) {
+ stream.reset(new ExternalOneByteStringUtf16CharacterStream(
+ Handle<ExternalOneByteString>::cast(source), 0, source->length()));
+ } else {
+ stream.reset(
+ new GenericStringUtf16CharacterStream(source, 0, source->length()));
+ }
+ scanner_.Initialize(stream.get());
result = DoParseProgram(info);
}
if (result != NULL) {
« no previous file with comments | « no previous file | src/parsing/scanner-character-streams.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698