Subject: | strictures.pm unnecessarily loads constant.pm, utf8_heavy.pl, etc. |
strictures defines a constant using constant.pm.
The versions of constant.pm bundled with Perl prior to 5.18 are a little heavier than would be nice. (This has been addressed in the 5.18.x releases of Perl, and in the CPAN releases of constant.)
However, for people with older versions of constant.pm, it would be nice if strictures avoided loading it.
A patch is attached to solve this. On my netbook, using Perl 5.16.2, before the patch, I get times like the following:
$ time perl -Istrictures-1.004004/lib -Mstrictures -e1
0.104u 0.004s 0:00.11 90.9% 0+0k 0+0io 0pf+0w
$ time perl -Istrictures-1.004004/lib -Mstrictures -e1
0.100u 0.008s 0:00.12 83.3% 0+0k 0+0io 0pf+0w
And after applying the patch, I get the following:
$ time perl -Istrictures-dev/lib -Mstrictures -e1
0.020u 0.008s 0:00.03 66.6% 0+0k 0+0io 0pf+0w
$ time perl -Istrictures-dev/lib -Mstrictures -e1
0.012u 0.016s 0:00.02 100.0% 0+0k 0+0io 0pf+0w
So it does make a small, but measurable difference to load times.
Subject: | strictures-no-constantpm.patch |
diff -urN strictures-1.004004/lib/strictures.pm strictures-dev/lib/strictures.pm
--- strictures-1.004004/lib/strictures.pm 2012-11-12 19:04:07.000000000 +0000
+++ strictures-dev/lib/strictures.pm 2013-08-18 20:25:28.127643048 +0100
@@ -3,7 +3,7 @@
use strict;
use warnings FATAL => 'all';
-use constant _PERL_LT_5_8_4 => ($] < 5.008004) ? 1 : 0;
+BEGIN { *_PERL_LT_5_8_4 = ($] < 5.008004) ? sub(){1} : sub(){0} };
our $VERSION = '1.004004'; # 1.4.4