tag:blogger.com,1999:blog-7760425276056032223.post3478404451434096981..comments2023-03-19T05:45:18.791-07:00Comments on PLABO: [Perl] Removig spaces from stringsPablo Marin-Garciahttp://www.blogger.com/profile/17942399687345864870noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-7760425276056032223.post-69237667892570953812010-05-20T03:48:39.148-07:002010-05-20T03:48:39.148-07:00@Illusori,
thanks, I remembered having read your ...@Illusori, <br />thanks, I remembered having read your blog entry and the flame war about optimization/profiling that your entry and a similar one in other blog started. But I was unable to remember where I read it. There was where I learnt about the speed difference and this is why I mention that the two lines option was faster but had no time to find the source so I leave that way, thanks for refreshing my memory.<br /><br />Your point about the macro is right . I can not help it,I like "perlgolfing" ;-).Pablo Marin-Garciahttps://www.blogger.com/profile/17942399687345864870noreply@blogger.comtag:blogger.com,1999:blog-7760425276056032223.post-54503234208038132132010-05-19T04:11:34.772-07:002010-05-19T04:11:34.772-07:00Even if it's not your bottleneck, if you'r...Even if it's not your bottleneck, if you're inserting the code by macro you might as well use the faster solution:<br /><br /> s/^\s+//g;<br /> s/\s+$//g;<br /><br />It's over 3 times faster even in the trivial case, and scales far better.<br /><br />If you're inserting it by macro then it's no extra effort to use. ;)<br /><br />I've covered this with hard figures in exhaustive detail in <a href="http://www.illusori.co.uk/perl/2010/03/05/advanced_benchmark_analysis_1.html" rel="nofollow">Advanced Benchmark Analysis I: Yet more white-space trimming</a> on my perl blog.<br /><br />As you say, not your bottleneck, but it's a trivial difference in effort and a good habit to form.Anonymousnoreply@blogger.com