Optimization
- Posted by Jason Gade <jaygade at yahoo.com> Feb 09, 2006
- 435 views
I know I've brought this up before, but I want to ask again. Does Euphoria optimize read-modify-write situation? I know that internally Euphoria passes by reference and only allocates a new sequence if elements are modified. But does the interpreter recognize the following:
sequence foo foo = bar(foo)
Is this optimized as a pattern where foo itself can be modified instead of allocating and returning a new sequence? Recognizing this optimization may be difficult, but I think that it would be very useful. I suppose where the variable are foo[1] or foo[1][2] or whatever would make things even more difficult. Maybe just for top-level references? Of course you could also have:
sequence foo foo = bar(baz, x, y, z, fun(foo), foo[1..a], d, foo, i, j)
Which would be truly horrid, but still... If Euphoria does this automatically it should be in the docs. Unless you'd actually implement a var_id() that is orthogonal with routine_id()... -- "Any programming problem can be solved by adding a level of indirection." --anonymous "Any performance problem can be solved by removing a level of indirection." --M. Haertel j.