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

Unified Diff: vm/object.cc

Issue 10414005: Remove script source from the snapshot in order to reduce the size and to make the image size small… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 7 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 | « vm/object.h ('k') | vm/raw_object_snapshot.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/object.cc
===================================================================
--- vm/object.cc (revision 7771)
+++ vm/object.cc (working copy)
@@ -4337,6 +4337,27 @@
}
+RawString* TokenStream::GenerateSource() const {
+ GrowableObjectArray& literals =
+ GrowableObjectArray::Handle(GrowableObjectArray::New(Length()));
+ String& literal = String::Handle();
+ String& blank = String::Handle(String::New(" "));
+ String& newline = String::Handle(String::New("\n"));
+ for (intptr_t i = 0; i < Length(); i++) {
+ Token::Kind kind = KindAt(i);
+ literal = LiteralAt(i);
+ literals.Add(literal);
+ if (kind == Token::kLBRACE) {
+ literals.Add(newline);
+ } else {
+ literals.Add(blank);
+ }
+ }
+ const Array& source = Array::Handle(Array::MakeArray(literals));
+ return String::ConcatAll(source);
+}
+
+
RawTokenStream* TokenStream::New(intptr_t len) {
const Class& token_stream_class = Class::Handle(Object::token_stream_class());
TokenStream& result = TokenStream::Handle();
@@ -4375,6 +4396,17 @@
}
+RawString* Script::source() const {
+ String& source = String::Handle(raw_ptr()->source_);
+ if (source.IsNull()) {
+ const TokenStream& token_stream = TokenStream::Handle(tokens());
+ return token_stream.GenerateSource();
+ } else {
+ return raw_ptr()->source_;
+ }
+}
+
+
void Script::set_url(const String& value) const {
StorePointer(&raw_ptr()->url_, value.raw());
}
« no previous file with comments | « vm/object.h ('k') | vm/raw_object_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698