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

Unified Diff: src/objects.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/inspector/debugger_script_externs.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index f5c8693d50f248a2ebff0279cecfede4d496f9ac..53ce1eba0d13d07130f8d07d9a637edefb637542 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -13375,23 +13375,17 @@ void Script::InitLineEnds(Handle<Script> script) {
Isolate* isolate = script->GetIsolate();
if (!script->line_ends()->IsUndefined(isolate)) return;
- if (!script->source()->IsString()) {
- DCHECK(script->source()->IsUndefined(isolate));
- Handle<FixedArray> empty = isolate->factory()->NewFixedArray(0);
- script->set_line_ends(*empty);
- DCHECK(script->line_ends()->IsFixedArray());
- return;
- }
-
- Handle<String> src(String::cast(script->source()), isolate);
-
- Handle<FixedArray> array = String::CalculateLineEnds(src, true);
-
- if (*array != isolate->heap()->empty_fixed_array()) {
- array->set_map(isolate->heap()->fixed_cow_array_map());
+ Object* src_obj = script->source();
+ if (!src_obj->IsString()) {
+ DCHECK(src_obj->IsUndefined(isolate));
+ script->set_line_ends(isolate->heap()->empty_fixed_array());
+ } else {
+ DCHECK(src_obj->IsString());
+ Handle<String> src(String::cast(src_obj), isolate);
+ Handle<FixedArray> array = String::CalculateLineEnds(src, true);
+ script->set_line_ends(*array);
}
- script->set_line_ends(*array);
DCHECK(script->line_ends()->IsFixedArray());
}
« no previous file with comments | « src/inspector/debugger_script_externs.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698