enhancement
The following TL-Script function is optimized by Top-Logic to a database query that returns a result very quickly:
all(`myModule:myType`).filter(x -> $x.get(`myModule:myType#id`) == "4711")
However, if you outsource exactly the same thing to a method and call it, no optimization takes place and the result calculation takes many times longer:
calcValue = id -> { all(`myModule:myType`).filter(x -> $x.get(`myModule:myType#id`) == $id) }; $calcValue("4711")
This problem occurs, for example, if you have an endpoint in the REST server with the parameter "searchedID" and then make a call in this endpoint like:
all(`myModule:myType`).filter(x -> $x.get(`myModule:myType#id`) == "searchedID")