[Gambas-user] Is the &= efficient?

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


Thanks, I like my sugar sweet, but not expensive.

I knew about, and was referring to:

http://gambaswiki.org/wiki/lang/alloc
http://gambaswiki.org/wiki/lang/memory
http://gambaswiki.org/wiki/lang/free

I hadn't seen this:

http://gambaswiki.org/wiki/lang/openstring

So, I assume the distinction is knowing where the data is during the building and the latter helps protect you against overruns.

Would varptr find the destination string before the stream is closed?

Are their any performance considerations between those two?


----- Original Message -----
From: "Benoît Minisini" <g4mba5 at gmail.com>

&= is just syntactic sugar. A &= B is the same thing as A = A & B, and 
so using &= for adding a string to a buffer does a lot of useless 
allocations.

Two workarounds:

1) Using a second string as an intermediate buffer.

2) Using OPEN STRING instruction. It implements a string buffer, and so 
does less allocations.

Regards,

-- 
Benoît Minisini

----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----


More information about the User mailing list