summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2018-03-11 14:23:42 -0700
committerFather Chrysostomos <sprout@cpan.org>2018-03-11 17:23:33 -0700
commit06afc688394f2ee3027d9ab81e7fa58256a91645 (patch)
tree0051060e8f1827c5620795069ea5511e06f430d2 /lib
parentb43c8b6097ab8a06b5e3f161de81ecdc3b88cffa (diff)
downloadperl-06afc688394f2ee3027d9ab81e7fa58256a91645.tar.gz
warnings.pm: sprintf is faster than concat
I benchmarked this line alone in a one-liner and found the sprintf variant to be roughly 10% faster than the concat version. It’s also more readable (and maintainable). (Not significant enough to warrant a perldelta entry.)
Diffstat (limited to 'lib')
-rw-r--r--lib/warnings.pm5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/warnings.pm b/lib/warnings.pm
index afb7934ab5..43d3925936 100644
--- a/lib/warnings.pm
+++ b/lib/warnings.pm
@@ -452,8 +452,9 @@ sub __chk
if ($has_level and @callers_bitmask) {
# logic copied from util.c:mess_sv
my $stuff = " at " . join " line ", (caller $i)[1,2];
- $stuff .= ", <" . *${^LAST_FH}{NAME} . "> "
- . ($/ eq "\n" ? "line" : "chunk") . " $."
+ $stuff .= sprintf ", <%s> %s %d",
+ *${^LAST_FH}{NAME},
+ ($/ eq "\n" ? "line" : "chunk"), $.
if $. && ${^LAST_FH};
die "$message$stuff.\n" if $results[0];
return warn "$message$stuff.\n";