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

Unified Diff: src/api.cc

Issue 2490903002: Simplify accesses to Script::line_ends (Closed)
Patch Set: Address comments Created 4 years, 1 month 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 | « src/accessors.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index d3a180cee9d5a478797a72198bd81f3f75fbac28..a414f00f297b6c61ade4339532ea03c6f9d66173 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -8880,22 +8880,16 @@ int DebugInterface::Script::ColumnOffset() const {
}
std::vector<int> DebugInterface::Script::LineEnds() const {
- i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
+ i::Handle<i::Script> script = Utils::OpenHandle(this);
+ i::Isolate* isolate = script->GetIsolate();
i::HandleScope scope(isolate);
- i::Script::InitLineEnds(Utils::OpenHandle(this));
- i::Handle<i::Object> line_ends_obj(Utils::OpenHandle(this)->line_ends(),
- isolate);
- std::vector<int> result;
- if (!line_ends_obj->IsFixedArray()) return result;
- i::Handle<i::FixedArray> line_ends =
- i::Handle<i::FixedArray>::cast(line_ends_obj);
+ i::Script::InitLineEnds(script);
+ CHECK(script->line_ends()->IsFixedArray());
+ i::Handle<i::FixedArray> line_ends(i::FixedArray::cast(script->line_ends()));
+ std::vector<int> result(line_ends->length());
for (int i = 0; i < line_ends->length(); ++i) {
- i::Handle<i::Object> line_end = i::FixedArray::get(*line_ends, i, isolate);
- if (line_end->IsSmi()) {
- result.push_back(i::Handle<i::Smi>::cast(line_end)->value());
- } else {
- result.push_back(0);
- }
+ i::Smi* line_end = i::Smi::cast(line_ends->get(i));
+ result[i] = line_end->value();
}
return result;
}
« no previous file with comments | « src/accessors.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698