Hacker News new | past | comments | ask | show | jobs | submit login

> 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.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: