Re: Tip of the week - Concetenation

new topic     » goto parent     » topic index » view thread      » older message » newer message

Surely this could be optimized, especially with respect to literals as the examples show?

I thought that Euphoria sequences were optimized to where there was a bit of extra space allocated to the end where small concatenations and/or appends could be done without copying.

Of course, that wouldn't work too well in a loop where an arbitrary number of objects were appended to a sequence, but still.

Also, since sequences are heterogeneous, why would it do any copies at all? Each object member of the sequence is a character/atom, and the sequence contains pointers to each individual member, right? So concatenating and appending shouldn't involve copying at all, rather just adding a new pointer to the sequence?

It would only be when any existing member of a sequence is changed that a copy would have to be made.

This example really confuses me, and goes against the way that I thought that Euphoria always worked. I thought that it only made copies when necessary.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu