@alexeyvo , I'm OK with this refactoring. But please verify if the code creates a copy of the original Variant.
This can have a bad performance impact the larger the arrays we pass.
Theoretically the compiler could generate code to put a reference to the object returned by the function and play with the reference counting to keep it after you exit the scope, but I'm not counting on that.

From the moment we call VarArrayCreate() we need to verify how many times the object is copied and try to structure the code to minimize that. Worst case scenario the call to SetVariantProp may generate a copy (didn't check our Delphi folks implemented the function, the code is in TypInfo.pas)