summaryrefslogtreecommitdiff
path: root/core/object
diff options
context:
space:
mode:
authorGeorge Marques <george@gmarqu.es>2022-04-05 20:40:07 -0300
committerGeorge Marques <george@gmarqu.es>2022-04-05 20:40:07 -0300
commit62ad18a3a16867aebc03243e26ce0363b4020238 (patch)
treed1da584206158bae0a4f697d6115d35df6310db0 /core/object
parente4f0fc50f79336cf76beec40e5e8e5164b288714 (diff)
Remove argument name strings from release builds
They are not needed in release, so we can remove them to reduce the binary size.
Diffstat (limited to 'core/object')
-rw-r--r--core/object/class_db.cpp9
-rw-r--r--core/object/class_db.h14
-rw-r--r--core/object/method_bind.cpp2
3 files changed, 23 insertions, 2 deletions
diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp
index fd86a02b90..61ce965bc3 100644
--- a/core/object/class_db.cpp
+++ b/core/object/class_db.cpp
@@ -37,6 +37,8 @@
#define OBJTYPE_RLOCK RWLockRead _rw_lockr_(lock);
#define OBJTYPE_WLOCK RWLockWrite _rw_lockw_(lock);
+#ifdef DEBUG_METHODS_ENABLED
+
MethodDefinition D_METHOD(const char *p_name) {
MethodDefinition md;
md.name = StaticCString::create(p_name);
@@ -224,6 +226,8 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
return md;
}
+#endif
+
ClassDB::APIType ClassDB::current_api = API_CORE;
void ClassDB::set_current_api(APIType p_api) {
@@ -1420,8 +1424,13 @@ void ClassDB::bind_method_custom(const StringName &p_class, MethodBind *p_method
type->method_map[p_method->get_name()] = p_method;
}
+#ifdef DEBUG_METHODS_ENABLED
MethodBind *ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind, const MethodDefinition &method_name, const Variant **p_defs, int p_defcount) {
StringName mdname = method_name.name;
+#else
+MethodBind *ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind, const char *method_name, const Variant **p_defs, int p_defcount) {
+ StringName mdname = StaticCString::create(method_name);
+#endif
OBJTYPE_WLOCK;
ERR_FAIL_COND_V(!p_bind, nullptr);
diff --git a/core/object/class_db.h b/core/object/class_db.h
index 5da8523743..333a3307e2 100644
--- a/core/object/class_db.h
+++ b/core/object/class_db.h
@@ -45,6 +45,8 @@
#define DEFVAL(m_defval) (m_defval)
+#ifdef DEBUG_METHODS_ENABLED
+
struct MethodDefinition {
StringName name;
Vector<StringName> args;
@@ -70,6 +72,14 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8, const char *p_arg9, const char *p_arg10, const char *p_arg11, const char *p_arg12);
MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8, const char *p_arg9, const char *p_arg10, const char *p_arg11, const char *p_arg12, const char *p_arg13);
+#else
+
+// When DEBUG_METHODS_ENABLED is set this will let the engine know
+// the argument names for easier debugging.
+#define D_METHOD(m_c, ...) m_c
+
+#endif
+
class ClassDB {
public:
enum APIType {
@@ -134,7 +144,11 @@ public:
static HashMap<StringName, StringName> resource_base_extensions;
static HashMap<StringName, StringName> compat_classes;
+#ifdef DEBUG_METHODS_ENABLED
static MethodBind *bind_methodfi(uint32_t p_flags, MethodBind *p_bind, const MethodDefinition &method_name, const Variant **p_defs, int p_defcount);
+#else
+ static MethodBind *bind_methodfi(uint32_t p_flags, MethodBind *p_bind, const char *method_name, const Variant **p_defs, int p_defcount);
+#endif
static APIType current_api;
diff --git a/core/object/method_bind.cpp b/core/object/method_bind.cpp
index a79adb7c6c..a208c1a2b2 100644
--- a/core/object/method_bind.cpp
+++ b/core/object/method_bind.cpp
@@ -69,8 +69,6 @@ PropertyInfo MethodBind::get_argument_info(int p_argument) const {
PropertyInfo info = _gen_argument_type_info(p_argument);
#ifdef DEBUG_METHODS_ENABLED
info.name = p_argument < arg_names.size() ? String(arg_names[p_argument]) : String("arg" + itos(p_argument));
-#else
- info.name = String("arg" + itos(p_argument));
#endif
return info;
}