[Gambas-user] '&=' operator optimization
Jussi Lahtinen
jussi.lahtinen at gmail.com
Sat Apr 4 19:36:12 CEST 2020
And when checking documentation, it seems VarPtr() has changed... but JIT
still accepts the old way.
Now its test is fixed.
Jussi
On Sat, Apr 4, 2020 at 8:14 PM Jussi Lahtinen <jussi.lahtinen at gmail.com>
wrote:
> Sorry, I didn't notice you had fix it already. However there is still
> another bug, that can be seen only when JIT is disabled.
>
>
> Jussi
>
> On Sat, Apr 4, 2020 at 7:58 PM Jussi Lahtinen <jussi.lahtinen at gmail.com>
> wrote:
>
>> Current code fails in GambasTester. Could be due earlier bug.
>> I highly recommend to automatically run it after compilation. I know it's
>> ugly as hell, but it does its job a lot better than nothing.
>>
>> Jussi
>>
>> On Sat, Apr 4, 2020 at 5:32 PM Benoît Minisini <g4mba5 at gmail.com> wrote:
>>
>>> Hi,
>>>
>>> In the last commit, I implemented an optimization of a common usage
>>> pattern of the '&=' operator, where a string is actually used as an
>>> accumulation buffer.
>>>
>>> Look at the following code, where a global string is filled with
>>> arbitrary strings:
>>>
>>> Private $sBuffer As String
>>>
>>> Public Sub Main()
>>>
>>> Dim I As Integer
>>> Dim C As String
>>> Dim J As Integer
>>> Dim T As Float
>>>
>>> T = Timer
>>> For I = 1 To 10000
>>> For J = 65 To 90
>>> C = Chr$(J)
>>> $sBuffer &= ".(" & C & ")"
>>> Next
>>> Next
>>>
>>> Print Len($sBuffer);; Timer - T
>>>
>>> End
>>>
>>> Before the optimization, that code runs in about 6.64 seconds.
>>>
>>> After the optimization, it runs in 0.026 seconds. More than 250 times
>>> faster!
>>>
>>> Note that the optimization works only if the string buffer is a local or
>>> global variable.
>>>
>>> If you detect any problem or any crash with that optimization, tell me.
>>>
>>> Regards,
>>>
>>> --
>>> Benoît Minisini
>>>
>>> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20200404/4e1c4ead/attachment.html>
More information about the User
mailing list