diff options
| author | Niels van Dijke <perlboy@cpan.org> | 2021-05-05 08:24:11 +0000 |
|---|---|---|
| committer | Niels van Dijke <perlboy@cpan.org> | 2021-05-05 08:24:11 +0000 |
| commit | 8c9455415a320bc055b1b2e07a1553c698bcb10b (patch) | |
| tree | 001ebfe75d325f415c8bce9bbf0be20fb2c5e0ef | |
| parent | 5331a796c387ae677f0662fa0376228022cbf52d (diff) | |
| download | perlweeklychallenge-club-8c9455415a320bc055b1b2e07a1553c698bcb10b.tar.gz perlweeklychallenge-club-8c9455415a320bc055b1b2e07a1553c698bcb10b.tar.bz2 perlweeklychallenge-club-8c9455415a320bc055b1b2e07a1553c698bcb10b.zip | |
Move from 'unpack' back to split('').
After some benchmarking I came to the conclusion split is faster.
| -rwxr-xr-x | challenge-111/perlboy1967/perl/ch-2.pl | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/challenge-111/perlboy1967/perl/ch-2.pl b/challenge-111/perlboy1967/perl/ch-2.pl index 3ca8cf7463..1b69c5013a 100755 --- a/challenge-111/perlboy1967/perl/ch-2.pl +++ b/challenge-111/perlboy1967/perl/ch-2.pl @@ -39,8 +39,7 @@ sub findLongestOrderedWords($) { for my $word (sort { length($b) <=> length($a) } grep /^[a-z]+$/,@inWords) { my $wlen = length($word); if (!defined $wlenMax or $wlenMax == $wlen) { - # Use unpack as it is slightly faster than split(//) - if ($word eq join('',sort unpack '(A1)*',$word)) { + if ($word eq join('',sort split '',$word)) { push(@words, $word); $wlenMax = $wlen; } |
