DoubleDeez / MDFramework

A multiplayer C# game framework for Godot 3.4 Mono.
https://discord.gg/UH49eHK
MIT License
77 stars 13 forks source link

Caching of reflection data #109

Closed Beider closed 3 years ago

Beider commented 3 years ago

The MDFramework relies heavily on reflection, however reflection is rather slow. This is particularly apparent inside

MDGameInstance.RegisterNewNode(Node Instance)

To solve this problem a reflection data cache should be added, preferably this should be hidden inside MDStatics / MD*Extensions and be used across the entire framework. It would also be good if this cache was accessible for the people who use the framework so they can use the same cache for their own reflection needs.

Beider commented 3 years ago

A few followups to this,

An idea for precaching would be to have a few methods like,

// Precahce just the given type
this.GetMDReflectionCache().PreCahceType(type);

// Precache the list of types
this.GetMDReflectionCache().PreCahceTypes(List<Type>);

// Precahce everything in a namespace
this.GetMDReflectionCache().PreCahceTypesInNamespace(string namespaceName);