Currently, Literal generates and evaluates code each time you define a property, which means it is O(n²).
This is not a big problem because it’s rare for an object to have more than a handful of properties. And Ruby is pretty fast. However, it would be much more efficient if we could do this only once after all properties have been specified.
Two options come to mind:
- Use the
:end TracePoint and a patch to Class.new
- Use a pre-processor like
strict_ivars
Currently, Literal generates and evaluates code each time you define a property, which means it is O(n²).
This is not a big problem because it’s rare for an object to have more than a handful of properties. And Ruby is pretty fast. However, it would be much more efficient if we could do this only once after all properties have been specified.
Two options come to mind:
:endTracePoint and a patch toClass.newstrict_ivars