[strip-nondeterminism] 02/03: File::SND: Lazy load remaining handlers

Chris Lamb chris at chris-lamb.co.uk
Mon Jul 10 21:08:05 UTC 2017


This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch master
in repository strip-nondeterminism.

commit 71037f0331b8ae8f7cb88e229bf61159c2cd894a
Author: Niels Thykier <niels at thykier.net>
Date:   Mon Jul 10 20:26:25 2017 +0000

    File::SND: Lazy load remaining handlers
    
    With this and the previous patch, the start up time of
    dh_strip_nondeterminism is now reduced to ~0.075s (from a start of
    ~0.17s) in the noop case.
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 lib/File/StripNondeterminism.pm | 33 +++++++++++++++------------------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/lib/File/StripNondeterminism.pm b/lib/File/StripNondeterminism.pm
index c153b0e..b50d41e 100644
--- a/lib/File/StripNondeterminism.pm
+++ b/lib/File/StripNondeterminism.pm
@@ -22,9 +22,6 @@ use strict;
 use warnings;
 
 use POSIX qw(tzset);
-use File::StripNondeterminism::handlers::javadoc;
-use File::StripNondeterminism::handlers::pearregistry;
-use File::StripNondeterminism::handlers::javaproperties;
 
 our($VERSION, $canonical_time, $clamp_time);
 
@@ -72,29 +69,29 @@ sub get_normalizer_for_file($) {
 		return _handler('jar');
 	}
 	# javadoc
-	if (m/\.html$/
-		&& File::StripNondeterminism::handlers::javadoc::is_javadoc_file($_)) {
-		return _handler('javadoc');
+	if (m/\.html$/) {
+		# Loading the handler forces the load of the javadoc package as well
+		my $handler = _handler('javadoc');
+		return $handler
+			if File::StripNondeterminism::handlers::javadoc::is_javadoc_file($_);
 	}
 	# pear registry
-	if (
-		m/\.reg$/
-		&& File::StripNondeterminism::handlers::pearregistry::is_registry_file(
-			$_)
-	  ) {
-		return _handler('pearregistry');
+	if (m/\.reg$/) {
+		# Loading the handler forces the load of the pearregistry package as well
+		my $handler = _handler('pearregistry');
+		return $handler
+			if File::StripNondeterminism::handlers::pearregistry::is_registry_file($_);
 	}
 	# PNG
 	if (m/\.png$/ && _get_file_type($_) =~ m/PNG image data/) {
 		return _handler('png');
 	}
 	# pom.properties, version.properties
-	if (
-		m/\.properties$/
-		&& File::StripNondeterminism::handlers::javaproperties::is_java_properties_file(
-			$_)
-	  ) {
-		return _handler('javaproperties');
+	if (m/\.properties$/) {
+		# Loading the handler forces the load of the javaproperties package as well
+		my $handler = _handler('javaproperties');
+		return $handler
+			if File::StripNondeterminism::handlers::javaproperties::is_java_properties_file($_);
 	}
 	# zip
 	if (m/\.(zip|pk3|epub|whl|xpi|htb|zhfst|par)$/

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/strip-nondeterminism.git



More information about the Reproducible-commits mailing list