Remove several checks on DEBUG_RELEASE
These errors shouldn't be possible on a tested game. Remove the checks on release. Shaves about 10% off of tight loops.
This commit is contained in:
parent
520d84e042
commit
0a338a28d9
1 changed files with 13 additions and 4 deletions
|
@ -41,11 +41,12 @@ Variant *GDFunction::_get_variant(int p_address, GDInstance *p_instance, GDScrip
|
||||||
switch ((p_address & ADDR_TYPE_MASK) >> ADDR_BITS) {
|
switch ((p_address & ADDR_TYPE_MASK) >> ADDR_BITS) {
|
||||||
|
|
||||||
case ADDR_TYPE_SELF: {
|
case ADDR_TYPE_SELF: {
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
if (unlikely(!p_instance)) {
|
if (unlikely(!p_instance)) {
|
||||||
r_error = "Cannot access self without instance.";
|
r_error = "Cannot access self without instance.";
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return &self;
|
return &self;
|
||||||
} break;
|
} break;
|
||||||
case ADDR_TYPE_CLASS: {
|
case ADDR_TYPE_CLASS: {
|
||||||
|
@ -53,18 +54,22 @@ Variant *GDFunction::_get_variant(int p_address, GDInstance *p_instance, GDScrip
|
||||||
return &p_script->_static_ref;
|
return &p_script->_static_ref;
|
||||||
} break;
|
} break;
|
||||||
case ADDR_TYPE_MEMBER: {
|
case ADDR_TYPE_MEMBER: {
|
||||||
//member indexing is O(1)
|
#ifdef DEBUG_ENABLED
|
||||||
if (unlikely(!p_instance)) {
|
if (unlikely(!p_instance)) {
|
||||||
r_error = "Cannot access member without instance.";
|
r_error = "Cannot access member without instance.";
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
//member indexing is O(1)
|
||||||
return &p_instance->members[address];
|
return &p_instance->members[address];
|
||||||
} break;
|
} break;
|
||||||
case ADDR_TYPE_CLASS_CONSTANT: {
|
case ADDR_TYPE_CLASS_CONSTANT: {
|
||||||
|
|
||||||
//todo change to index!
|
//todo change to index!
|
||||||
GDScript *o = p_script;
|
GDScript *o = p_script;
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
ERR_FAIL_INDEX_V(address, _global_names_count, NULL);
|
ERR_FAIL_INDEX_V(address, _global_names_count, NULL);
|
||||||
|
#endif
|
||||||
const StringName *sn = &_global_names_ptr[address];
|
const StringName *sn = &_global_names_ptr[address];
|
||||||
|
|
||||||
while (o) {
|
while (o) {
|
||||||
|
@ -84,18 +89,22 @@ Variant *GDFunction::_get_variant(int p_address, GDInstance *p_instance, GDScrip
|
||||||
ERR_FAIL_V(NULL);
|
ERR_FAIL_V(NULL);
|
||||||
} break;
|
} break;
|
||||||
case ADDR_TYPE_LOCAL_CONSTANT: {
|
case ADDR_TYPE_LOCAL_CONSTANT: {
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
ERR_FAIL_INDEX_V(address, _constant_count, NULL);
|
ERR_FAIL_INDEX_V(address, _constant_count, NULL);
|
||||||
|
#endif
|
||||||
return &_constants_ptr[address];
|
return &_constants_ptr[address];
|
||||||
} break;
|
} break;
|
||||||
case ADDR_TYPE_STACK:
|
case ADDR_TYPE_STACK:
|
||||||
case ADDR_TYPE_STACK_VARIABLE: {
|
case ADDR_TYPE_STACK_VARIABLE: {
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
ERR_FAIL_INDEX_V(address, _stack_size, NULL);
|
ERR_FAIL_INDEX_V(address, _stack_size, NULL);
|
||||||
|
#endif
|
||||||
return &p_stack[address];
|
return &p_stack[address];
|
||||||
} break;
|
} break;
|
||||||
case ADDR_TYPE_GLOBAL: {
|
case ADDR_TYPE_GLOBAL: {
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
ERR_FAIL_INDEX_V(address, GDScriptLanguage::get_singleton()->get_global_array_size(), NULL);
|
ERR_FAIL_INDEX_V(address, GDScriptLanguage::get_singleton()->get_global_array_size(), NULL);
|
||||||
|
#endif
|
||||||
return &GDScriptLanguage::get_singleton()->get_global_array()[address];
|
return &GDScriptLanguage::get_singleton()->get_global_array()[address];
|
||||||
} break;
|
} break;
|
||||||
case ADDR_TYPE_NIL: {
|
case ADDR_TYPE_NIL: {
|
||||||
|
|
Loading…
Reference in a new issue