Skip to content

Commit 8f90102

Browse files
committed
Reduce changes in refcounts in gdscript vm
1 parent a864370 commit 8f90102

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

modules/gdscript/gdscript_vm.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ static bool _profile_count_as_native(const Object *p_base_obj, const StringName
4242
if (!p_base_obj) {
4343
return false;
4444
}
45-
StringName cname = p_base_obj->get_class_name();
46-
if ((p_methodname == "new" && cname == "GDScript") || p_methodname == "call") {
45+
const StringName &cname = p_base_obj->get_class_name();
46+
if ((p_methodname == SNAME("new") && cname == GDScript::get_class_static()) || p_methodname == CoreStringName(call)) {
4747
return false;
4848
}
4949
return ClassDB::class_exists(cname) && ClassDB::has_method(cname, p_methodname, false);
@@ -886,7 +886,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
886886
Variant::Type builtin_type = (Variant::Type)_code_ptr[ip + 4];
887887
int native_type_idx = _code_ptr[ip + 5];
888888
GD_ERR_BREAK(native_type_idx < 0 || native_type_idx >= _global_names_count);
889-
const StringName native_type = _global_names_ptr[native_type_idx];
889+
const StringName &native_type = _global_names_ptr[native_type_idx];
890890

891891
bool result = false;
892892
if (value->get_type() == Variant::ARRAY) {
@@ -909,13 +909,13 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
909909
Variant::Type key_builtin_type = (Variant::Type)_code_ptr[ip + 5];
910910
int key_native_type_idx = _code_ptr[ip + 6];
911911
GD_ERR_BREAK(key_native_type_idx < 0 || key_native_type_idx >= _global_names_count);
912-
const StringName key_native_type = _global_names_ptr[key_native_type_idx];
912+
const StringName &key_native_type = _global_names_ptr[key_native_type_idx];
913913

914914
GET_VARIANT_PTR(value_script_type, 3);
915915
Variant::Type value_builtin_type = (Variant::Type)_code_ptr[ip + 7];
916916
int value_native_type_idx = _code_ptr[ip + 8];
917917
GD_ERR_BREAK(value_native_type_idx < 0 || value_native_type_idx >= _global_names_count);
918-
const StringName value_native_type = _global_names_ptr[value_native_type_idx];
918+
const StringName &value_native_type = _global_names_ptr[value_native_type_idx];
919919

920920
bool result = false;
921921
if (value->get_type() == Variant::DICTIONARY) {
@@ -937,7 +937,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
937937

938938
int native_type_idx = _code_ptr[ip + 3];
939939
GD_ERR_BREAK(native_type_idx < 0 || native_type_idx >= _global_names_count);
940-
const StringName native_type = _global_names_ptr[native_type_idx];
940+
const StringName &native_type = _global_names_ptr[native_type_idx];
941941

942942
bool was_freed = false;
943943
Object *object = value->get_validated_object_with_check(was_freed);
@@ -1460,7 +1460,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
14601460
Variant::Type builtin_type = (Variant::Type)_code_ptr[ip + 4];
14611461
int native_type_idx = _code_ptr[ip + 5];
14621462
GD_ERR_BREAK(native_type_idx < 0 || native_type_idx >= _global_names_count);
1463-
const StringName native_type = _global_names_ptr[native_type_idx];
1463+
const StringName &native_type = _global_names_ptr[native_type_idx];
14641464

14651465
if (src->get_type() != Variant::ARRAY) {
14661466
#ifdef DEBUG_ENABLED
@@ -1495,13 +1495,13 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
14951495
Variant::Type key_builtin_type = (Variant::Type)_code_ptr[ip + 5];
14961496
int key_native_type_idx = _code_ptr[ip + 6];
14971497
GD_ERR_BREAK(key_native_type_idx < 0 || key_native_type_idx >= _global_names_count);
1498-
const StringName key_native_type = _global_names_ptr[key_native_type_idx];
1498+
const StringName &key_native_type = _global_names_ptr[key_native_type_idx];
14991499

15001500
GET_VARIANT_PTR(value_script_type, 3);
15011501
Variant::Type value_builtin_type = (Variant::Type)_code_ptr[ip + 7];
15021502
int value_native_type_idx = _code_ptr[ip + 8];
15031503
GD_ERR_BREAK(value_native_type_idx < 0 || value_native_type_idx >= _global_names_count);
1504-
const StringName value_native_type = _global_names_ptr[value_native_type_idx];
1504+
const StringName &value_native_type = _global_names_ptr[value_native_type_idx];
15051505

15061506
if (src->get_type() != Variant::DICTIONARY) {
15071507
#ifdef DEBUG_ENABLED
@@ -1815,7 +1815,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
18151815
Variant::Type builtin_type = (Variant::Type)_code_ptr[ip + 2];
18161816
int native_type_idx = _code_ptr[ip + 3];
18171817
GD_ERR_BREAK(native_type_idx < 0 || native_type_idx >= _global_names_count);
1818-
const StringName native_type = _global_names_ptr[native_type_idx];
1818+
const StringName &native_type = _global_names_ptr[native_type_idx];
18191819

18201820
Array array;
18211821
array.set_typed(builtin_type, native_type, *script_type);
@@ -1870,13 +1870,13 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
18701870
Variant::Type key_builtin_type = (Variant::Type)_code_ptr[ip + 2];
18711871
int key_native_type_idx = _code_ptr[ip + 3];
18721872
GD_ERR_BREAK(key_native_type_idx < 0 || key_native_type_idx >= _global_names_count);
1873-
const StringName key_native_type = _global_names_ptr[key_native_type_idx];
1873+
const StringName &key_native_type = _global_names_ptr[key_native_type_idx];
18741874

18751875
GET_INSTRUCTION_ARG(value_script_type, argc * 2 + 2);
18761876
Variant::Type value_builtin_type = (Variant::Type)_code_ptr[ip + 4];
18771877
int value_native_type_idx = _code_ptr[ip + 5];
18781878
GD_ERR_BREAK(value_native_type_idx < 0 || value_native_type_idx >= _global_names_count);
1879-
const StringName value_native_type = _global_names_ptr[value_native_type_idx];
1879+
const StringName &value_native_type = _global_names_ptr[value_native_type_idx];
18801880

18811881
Dictionary dict;
18821882
dict.set_typed(key_builtin_type, key_native_type, *key_script_type, value_builtin_type, value_native_type, *value_script_type);
@@ -2409,7 +2409,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
24092409
GD_ERR_BREAK(argc < 0);
24102410

24112411
GD_ERR_BREAK(_code_ptr[ip + 2] < 0 || _code_ptr[ip + 2] >= _global_names_count);
2412-
StringName function = _global_names_ptr[_code_ptr[ip + 2]];
2412+
const StringName &function = _global_names_ptr[_code_ptr[ip + 2]];
24132413

24142414
Variant **argptrs = instruction_args;
24152415

@@ -2848,7 +2848,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
28482848
Variant::Type builtin_type = (Variant::Type)_code_ptr[ip + 3];
28492849
int native_type_idx = _code_ptr[ip + 4];
28502850
GD_ERR_BREAK(native_type_idx < 0 || native_type_idx >= _global_names_count);
2851-
const StringName native_type = _global_names_ptr[native_type_idx];
2851+
const StringName &native_type = _global_names_ptr[native_type_idx];
28522852

28532853
if (r->get_type() != Variant::ARRAY) {
28542854
#ifdef DEBUG_ENABLED
@@ -2884,13 +2884,13 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
28842884
Variant::Type key_builtin_type = (Variant::Type)_code_ptr[ip + 4];
28852885
int key_native_type_idx = _code_ptr[ip + 5];
28862886
GD_ERR_BREAK(key_native_type_idx < 0 || key_native_type_idx >= _global_names_count);
2887-
const StringName key_native_type = _global_names_ptr[key_native_type_idx];
2887+
const StringName &key_native_type = _global_names_ptr[key_native_type_idx];
28882888

28892889
GET_VARIANT_PTR(value_script_type, 2);
28902890
Variant::Type value_builtin_type = (Variant::Type)_code_ptr[ip + 6];
28912891
int value_native_type_idx = _code_ptr[ip + 7];
28922892
GD_ERR_BREAK(value_native_type_idx < 0 || value_native_type_idx >= _global_names_count);
2893-
const StringName value_native_type = _global_names_ptr[value_native_type_idx];
2893+
const StringName &value_native_type = _global_names_ptr[value_native_type_idx];
28942894

28952895
if (r->get_type() != Variant::DICTIONARY) {
28962896
#ifdef DEBUG_ENABLED

0 commit comments

Comments
 (0)