mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 08:20:31 +00:00
[VM] Use Symbols::Empty() when there is no source for a script instead of creating new empty string objects.
Change-Id: I8ec6702557b07c4c4ede2aece5a3f25b4cde1a5b Reviewed-on: https://dart-review.googlesource.com/c/79060 Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Siva Annamalai <asiva@google.com>
This commit is contained in:
parent
72b31316e4
commit
a933f42b9e
3 changed files with 16 additions and 8 deletions
|
@ -2507,12 +2507,17 @@ String& KernelReaderHelper::SourceTableUriFor(intptr_t index) {
|
|||
return H.DartString(reader_.BufferAt(ReaderOffset()), size, Heap::kOld);
|
||||
}
|
||||
|
||||
String& KernelReaderHelper::GetSourceFor(intptr_t index) {
|
||||
const String& KernelReaderHelper::GetSourceFor(intptr_t index) {
|
||||
AlternativeReadingScope alt(&reader_);
|
||||
SetOffset(GetOffsetForSourceInfo(index));
|
||||
SkipBytes(ReadUInt()); // skip uri.
|
||||
intptr_t size = ReadUInt(); // read source List<byte> size.
|
||||
return H.DartString(reader_.BufferAt(ReaderOffset()), size, Heap::kOld);
|
||||
ASSERT(size >= 0);
|
||||
if (size == 0) {
|
||||
return Symbols::Empty();
|
||||
} else {
|
||||
return H.DartString(reader_.BufferAt(ReaderOffset()), size, Heap::kOld);
|
||||
}
|
||||
}
|
||||
|
||||
RawTypedData* KernelReaderHelper::GetLineStartsFor(intptr_t index) {
|
||||
|
|
|
@ -1028,7 +1028,7 @@ class KernelReaderHelper {
|
|||
intptr_t SourceTableSize();
|
||||
intptr_t GetOffsetForSourceInfo(intptr_t index);
|
||||
String& SourceTableUriFor(intptr_t index);
|
||||
String& GetSourceFor(intptr_t index);
|
||||
const String& GetSourceFor(intptr_t index);
|
||||
RawTypedData* GetLineStartsFor(intptr_t index);
|
||||
|
||||
Zone* zone_;
|
||||
|
|
|
@ -1776,11 +1776,12 @@ const Object& KernelLoader::ClassForScriptAt(const Class& klass,
|
|||
|
||||
RawScript* KernelLoader::LoadScriptAt(intptr_t index) {
|
||||
const String& uri_string = helper_.SourceTableUriFor(index);
|
||||
String& sources = helper_.GetSourceFor(index);
|
||||
const String& script_source = helper_.GetSourceFor(index);
|
||||
String& sources = String::Handle(Z);
|
||||
TypedData& line_starts =
|
||||
TypedData::Handle(Z, helper_.GetLineStartsFor(index));
|
||||
if (sources.Length() == 0 && line_starts.Length() == 0 &&
|
||||
uri_string.Length() > 0) {
|
||||
if (script_source.raw() == Symbols::Empty().raw() &&
|
||||
line_starts.Length() == 0 && uri_string.Length() > 0) {
|
||||
// Entry included only to provide URI - actual source should already exist
|
||||
// in the VM, so try to find it.
|
||||
Library& lib = Library::Handle(Z);
|
||||
|
@ -1796,6 +1797,8 @@ RawScript* KernelLoader::LoadScriptAt(intptr_t index) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sources = script_source.raw();
|
||||
}
|
||||
|
||||
const Script& script = Script::Handle(
|
||||
|
@ -1805,8 +1808,8 @@ RawScript* KernelLoader::LoadScriptAt(intptr_t index) {
|
|||
script.set_kernel_script_index(index);
|
||||
script.set_kernel_program_info(kernel_program_info_);
|
||||
script.set_line_starts(line_starts);
|
||||
script.set_debug_positions(Array::Handle(Array::null()));
|
||||
script.set_yield_positions(Array::Handle(Array::null()));
|
||||
script.set_debug_positions(Array::null_array());
|
||||
script.set_yield_positions(Array::null_array());
|
||||
return script.raw();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue