Is it interesting to generate native code that is more complex but faster than dynamic Groovy implementation?
For example: collect(ref)->isEmpty is translated into getRef(ref).asList().isEmpty(). This implementation is not efficient: getRef returns an Iterable that is filled from the database. If we put it in a list we force the database to load everything just to check if there is at least one element in the list.
Another approach is to dynamically add Iterable.metaClass.isEmpty to the init Groovy script, with an optimized implementation: !this.hasNext(). But Groovy dynamic dispatch is very slow, especially for closure-based methods.
For now I use the first solution, but I don't think it is the most interesting in the general case, need to to some experiments.
Is it interesting to generate native code that is more complex but faster than dynamic Groovy implementation?
For example:
collect(ref)->isEmpty
is translated intogetRef(ref).asList().isEmpty()
. This implementation is not efficient: getRef returns an Iterable that is filled from the database. If we put it in a list we force the database to load everything just to check if there is at least one element in the list.Another approach is to dynamically add
Iterable.metaClass.isEmpty
to the init Groovy script, with an optimized implementation:!this.hasNext()
. But Groovy dynamic dispatch is very slow, especially for closure-based methods.For now I use the first solution, but I don't think it is the most interesting in the general case, need to to some experiments.