annotate intentional lvalue substr
authorMischa POSLAWSKY <perl@shiar.org>
Mon, 21 Feb 2022 13:25:00 +0000 (14:25 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Sun, 17 Apr 2022 17:20:25 +0000 (19:20 +0200)
Advised against by perlcritic and PBP because of confusion and efficiency.
The latter seems contrary to actual benchmark results in v5.24-5.28,
where this form is at least 5% faster (even with a dummy length argument).

barcat

diff --git a/barcat b/barcat
index b0237c4eb249f923940f1c56df1376dfbd14a182..879624860a84d679ba05b82a65492d4c5795a576 100755 (executable)
--- a/barcat
+++ b/barcat
@@ -162,6 +162,7 @@ while (defined ($_ = $opt{input} ? shift @{ $opt{input} } : readline)) {
                        $_ = substr $_, 0, 2;
                }
                elsif (length > $trimpos) {
+                       # cut and replace (intentional lvalue for speed, contrary to PBP)
                        substr($_, $trimpos - 1) = '…';
                }
        }