2 ms·
> I can't reproduce this "bug" in either Perl or Python. You're doing it wrong then. #!/usr/bin/perl use Benchmark; sub trim { my $s=shift;
by lazyjones 10y ago
> I can't reproduce this "bug" in either Perl or Python.
You're doing it wrong then.
#!/usr/bin/perl
use Benchmark;
sub trim {
my $s=shift;
$s =~ s/^[\s\u200c]+|[\s\u200c]+$//g;
return $s;
}
timethis(100, sub { trim("x" . " " x 20000 . "x"); });
With Perl 5.18 I get 2.65/s on a fast iMac.