HandleScope scope(isolate);
Handle<JSObject> self(this);
- Handle<String> name;
Handle<Object> old_value;
- bool preexists = false;
- if (FLAG_harmony_observation && map()->is_observed()) {
- name = isolate->factory()->Uint32ToString(index);
- preexists = self->HasLocalElement(index);
- if (preexists) {
- old_value = GetLocalElementAccessorPair(index) != NULL
+ bool should_enqueue_change_record = false;
+ if (FLAG_harmony_observation && self->map()->is_observed()) {
+ should_enqueue_change_record = self->HasLocalElement(index);
+ if (should_enqueue_change_record) {
+ old_value = self->GetLocalElementAccessorPair(index) != NULL
? Handle<Object>::cast(isolate->factory()->the_hole_value())
: Object::GetElement(self, index);
}
Handle<Object> hresult;
if (!result->ToHandle(&hresult, isolate)) return result;
- if (FLAG_harmony_observation && map()->is_observed()) {
- if (preexists && !self->HasLocalElement(index))
- EnqueueChangeRecord(self, "deleted", name, old_value);
+ if (should_enqueue_change_record && !self->HasLocalElement(index)) {
+ Handle<String> name = isolate->factory()->Uint32ToString(index);
+ EnqueueChangeRecord(self, "deleted", name, old_value);
}
return *hresult;
Handle<String> hname(name);
Handle<Object> old_value(isolate->heap()->the_hole_value());
- if (FLAG_harmony_observation && map()->is_observed()) {
+ bool is_observed = FLAG_harmony_observation && self->map()->is_observed();
+ if (is_observed) {
old_value = handle(lookup.GetLazyValue(), isolate);
}
MaybeObject* result;
Handle<Object> hresult;
if (!result->ToHandle(&hresult, isolate)) return result;
- if (FLAG_harmony_observation && map()->is_observed()) {
- if (!self->HasLocalProperty(*hname))
- EnqueueChangeRecord(self, "deleted", hname, old_value);
+ if (is_observed && !self->HasLocalProperty(*hname)) {
+ EnqueueChangeRecord(self, "deleted", hname, old_value);
}
return *hresult;
bool is_element = name->AsArrayIndex(&index);
Handle<Object> old_value = isolate->factory()->the_hole_value();
+ bool is_observed = FLAG_harmony_observation && self->map()->is_observed();
bool preexists = false;
- if (FLAG_harmony_observation && map()->is_observed()) {
+ if (is_observed) {
if (is_element) {
preexists = HasLocalElement(index);
- if (preexists && GetLocalElementAccessorPair(index) == NULL) {
+ if (preexists && self->GetLocalElementAccessorPair(index) == NULL) {
old_value = Object::GetElement(self, index);
}
} else {
Handle<Object> hresult;
if (!result->ToHandle(&hresult, isolate)) return result;
- if (FLAG_harmony_observation && map()->is_observed()) {
+ if (is_observed) {
const char* type = preexists ? "reconfigured" : "new";
EnqueueChangeRecord(self, type, name, old_value);
}
Handle<Object> old_length;
if (old_attributes != ABSENT) {
- if (GetLocalElementAccessorPair(index) == NULL)
+ if (self->GetLocalElementAccessorPair(index) == NULL)
old_value = Object::GetElement(self, index);
} else if (self->IsJSArray()) {
// Store old array length in case adding an element grows the array.