Skip to content

Commit

Permalink
static inline is bad. Generates way too much code that the linker is …
Browse files Browse the repository at this point in the history
…unable to optimize and remove on final link. This causes these symbols from every class in godot-cpp to be included in the final link, even if completely unused by the lib. Removing changes a basic shared library from being ~1.5MB on almost all platforms to now ~200kB.
  • Loading branch information
jordo committed Oct 10, 2024
1 parent 6facde3 commit ddd03ee
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/godot_cpp/classes/ref.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class Ref {

// Used exclusively in the bindings to recreate the Ref Godot encapsulates in return values,
// without adding to the refcount.
inline static Ref<T> _gde_internal_constructor(Object *obj) {
static Ref<T> _gde_internal_constructor(Object *obj) {
Ref<T> r;
r.reference = (T *)obj;
return r;
Expand Down
4 changes: 2 additions & 2 deletions include/godot_cpp/classes/wrapped.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Wrapped {
GDExtensionObjectPtr owner;
RecreateInstance *next;
};
inline static RecreateInstance *recreate_instance = nullptr;
static RecreateInstance *recreate_instance;
#endif

void _notification(int p_what) {}
Expand Down Expand Up @@ -408,7 +408,7 @@ protected:
// Don't use this for your classes, use GDCLASS() instead.
#define GDEXTENSION_CLASS_ALIAS(m_class, m_alias_for, m_inherits) /******************************************************************************************************************/ \
private: \
inline static ::godot::internal::EngineClassRegistration<m_class> _gde_engine_class_registration_helper; \
static ::godot::internal::EngineClassRegistration<m_class> _gde_engine_class_registration_helper; \
void operator=(const m_class &p_rval) {} \
friend class ::godot::ClassDB; \
friend class ::godot::Wrapped; \
Expand Down
4 changes: 4 additions & 0 deletions src/classes/wrapped.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ namespace godot {
thread_local const StringName *Wrapped::_constructing_extension_class_name = nullptr;
thread_local const GDExtensionInstanceBindingCallbacks *Wrapped::_constructing_class_binding_callbacks = nullptr;

#ifdef HOT_RELOAD_ENABLED
Wrapped::RecreateInstance *Wrapped::recreate_instance = nullptr;
#endif

const StringName *Wrapped::_get_extension_class_name() {
return nullptr;
}
Expand Down

0 comments on commit ddd03ee

Please sign in to comment.