From what I hear, getting/setting dynamic properties is a lot slower than regular properties.
But does allowing a class to be dynamic slow down the entire class for regular property getting/setting?
For instance, let’s say I have this class (pretend those properties have setters as well):
public dynamic class Hero
{
public function get endurance():int
{ return _endurance; }
public function get strength():int
{ return _strength; }
public function hit(target:Enemy)
{ target.damage(this.strength); }
}
Since the class is dynamic, properties can be added on later, such as:
hero1[“magic”] = 500; or hero1.magic = 500;
Obviously, calling and setting the “magic” property will be a lot slower, but will all properties become slower to get/set just because the entire class is set to dynamic?
Is it better to not set the entire class to dynamic, and instead create a new dynamic object, “additionalStats” where properties can be get/set to instead?