Regarding complexity, returning or passing a link is like passing a pointer. Its overhead is equivalent to passing an integer to the size of a pointer plus a few instructions. In short, it is as fast as possible in almost every case. A striking exception is the built-in types (e.g. int, float) that are less than or equal to the size of the pointer.
In the worst case, passing / returning a link may add some instructions or disable some optimizations. These losses rarely exceed the cost of returning / transferring objects at a cost (for example, calling the copy constructor + destructor is much higher, even for a very simple object). Passing / returning by reference is a good default if each instruction is not counted and you have measured this difference.
Therefore, the use of links has an incredibly low cost.
It is impossible to quantify how much faster it would be without knowing the complexity of your types and their constructor / destructor, but if it is not a built-in type, then saving the local one and returning it by reference will be the fastest in most cases - it all depends on the complexity of the object and copies of it, but only incredibly trivial objects can approximate link speed.
source share