Skip to content

Commit

Permalink
Merge pull request #53015 from timothyqiu/cast-crash
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga authored Sep 26, 2021
2 parents 7893dd2 + 8a47fe9 commit 8fb06b4
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions core/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -804,22 +804,15 @@ bool Variant::is_one() const {
}

ObjectID Variant::get_object_instance_id() const {
if (type != OBJECT) {
if (unlikely(type != OBJECT)) {
return 0;
}
#ifdef DEBUG_ENABLED
if (is_ref()) {
return !_get_obj().ref.is_null() ? _REF_OBJ_PTR(*this)->get_instance_id() : 0;
} else {
} else if (likely(_get_obj().rc)) {
return _get_obj().rc->instance_id;
}
#else
if (is_ref() && _get_obj().ref.is_null()) {
return 0;
} else if (likely(!_get_obj().ref.is_null())) {
return _REF_OBJ_PTR(*this)->get_instance_id();
} else {
return _get_obj().rc->get_ptr()->get_instance_id();
return 0;
}
#endif
}

bool Variant::is_invalid_object() const {
Expand Down

0 comments on commit 8fb06b4

Please sign in to comment.