[Gambas-user] Is the &= efficient?

Cedron Dawg cedron at exede.net
Tue Mar 5 21:21:22 CET 2019


It has been mentioned in the past that Gambas doesn't have garbage collection, that objects are allocated in place.  In regular BASICS, and Java, etc, when a string append is performed, space for the new string is created, the old string copied, and the new string copied at the end.

So the question is, if one is appending a whole block of strings like this:

        x &= "long string constant"
        x &= "long again " & maybewith & "some replacement termst"
        .
        .
        .
             
Is it better to allocate a memory area and print to the memory instead?

Syntactically, I think the former is cleaner looking, but if there is a performance hit, that is not worth it.  The two variations are easily interchangeable via search and replace, so is not something I need to know immediately, but I'd like to know which is better.

Not worth a deep dive into the code yet though.

Thanks,
Ced



More information about the User mailing list