[Wellington-pm] Stripping spaces.

michael at diaspora.gen.nz michael at diaspora.gen.nz
Mon Oct 11 18:02:04 CDT 2004


Grant McLean writes:
>On Tue, 2004-10-12 at 09:31, Peter Love wrote:
>> >     s/^\s+//g; s/\s+$//g;
>> 
>> Why have the g modifier on these?  As they are anchored, surely there is 
>> only one occurence?
>
>Yes, the /g is unnecessary and including it does seem to make it a
>little slower.

True.  A typo on my part; it was still 30 times faster than the other
versions, on the test I gave it, so I didn't look closely.  I used longer
strings than you did with your dict and it therefore seems likely that
the behaviour is exponentially worse, instead of linear, in respect of
the size of the string.

    -- michael.


More information about the Wellington-pm mailing list