[Gambas-user] trimming extra spaces from within a string.

Fabien Bodard gambas.fr at gmail.com
Mon Nov 9 23:52:46 CET 2020


And .. sorry I'm on phone but

Just walk on the string if not space add to new string ...if first space
too... jump to the next not space letter ...etc ?

Is this not more faster than using a recursive call to replace ?

The 3 ms gain from benoit can come from the fact he not use trim.

Fabien


Le lun. 9 nov. 2020 à 23:47, Jussi Lahtinen <jussi.lahtinen at gmail.com> a
écrit :

> Sorry, not twice, once.
>
> Jussi
>
> On Tue, Nov 10, 2020 at 12:43 AM Jussi Lahtinen <jussi.lahtinen at gmail.com>
> wrote:
>
>> Your way is run only twice, the other ways are run 500 times. Thus it
>> seems your way is faster.
>> You already have this program, it is the IDE. See profiler.
>>
>> Jussi
>>
>>
>> On Tue, Nov 10, 2020 at 12:25 AM Bruce Steers <bsteers4 at gmail.com> wrote:
>>
>>> I'm reading it wrong aren't I :(
>>>
>>> looing at the InTrim snapshot it looks like it's using my method AND
>>> regexp too?
>>> so i don't think im reading it right at all lol.
>>> BruceS
>>>
>>> On Mon, 9 Nov 2020 at 22:14, Bruce Steers <bsteers4 at gmail.com> wrote:
>>>
>>>> I'm not sure if i'm reading those reports right , i had to look up
>>>> dauer to see it meant duration.
>>>> and what on earth is that program ?  i want it lol :)
>>>>
>>>> But from what i can see,,  my way was the fastest at 1.4 yes?
>>>>
>>>> this makes me happy as i initially used the "while and replace" method
>>>> then thought to improve it.
>>>> looks like i could not have done a better job eh? :)
>>>>
>>>> Unless i'm reading it all wrong?
>>>>
>>>> Thanks Christof , very enlightening :)
>>>>
>>>>
>>>> On Mon, 9 Nov 2020 at 20:44, Christof Thalhofer <chrisml at deganius.de>
>>>> wrote:
>>>>
>>>>> Am 09.11.20 um 19:38 schrieb Bruce Steers:
>>>>>
>>>>> > do you think using Replace() would be faster than my initial InTrim()
>>>>> > function method ?
>>>>>
>>>>> It's ultra-ultra-ultra-...repeat 1.000.000 times ...slow.
>>>>> I write this mail while it is running in the background ... 'til now, I
>>>>> stopped it.
>>>>>
>>>>> It needs about 1.4 seconds for a 314 k text. For the test which does
>>>>> the
>>>>> text 500 times it would need about 12 minutes.
>>>>>
>>>>> :-)
>>>>>
>>>>> Alles Gute
>>>>>
>>>>> Christof Thalhofer
>>>>>
>>>>> --
>>>>> Dies ist keine Signatur
>>>>>
>>>>> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>>>>>
>>>>
>>> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>>>
>>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20201109/888f18a8/attachment.htm>


More information about the User mailing list