-
Jean Boussier authored
CodeGenerator has multiple purposes. First it's too batch `class_eval` calls, because each call has a fixed cost , so by batching we're faster. Second it's to be able to generate methods with the proper source location. So that if a user introspect a method, it's pointed to the proper macro. And third, it is optionally to re-used generated method, typically attribute accessors are very often duplicated. Where it's used in Action View, there is no need for deduplication, so `defined_cached_method` is just extra work. Additionally, the source locations were incorrect because of the use of heredoc. This commit introduce `CodeGenerator#class_eval` for cases where we don't need duplication, and fixes the source locations.
Jean Boussier authoredCodeGenerator has multiple purposes. First it's too batch `class_eval` calls, because each call has a fixed cost , so by batching we're faster. Second it's to be able to generate methods with the proper source location. So that if a user introspect a method, it's pointed to the proper macro. And third, it is optionally to re-used generated method, typically attribute accessors are very often duplicated. Where it's used in Action View, there is no need for deduplication, so `defined_cached_method` is just extra work. Additionally, the source locations were incorrect because of the use of heredoc. This commit introduce `CodeGenerator#class_eval` for cases where we don't need duplication, and fixes the source locations.
Loading